AricC 1,892
Recognized Expert Top Contributor
Currently I am manually setting each control on my form to null to reset. Does anyone know how to do this with a loop or a more simple command? I've seen some make shift control arrays but none that would work for me.
Thanks,
Aric
12 16032 ADezii 8,834
Recognized Expert Expert
Currently I am manually setting each control on my form to null to reset. Does anyone know how to do this with a loop or a more simple command? I've seen some make shift control arrays but none that would work for me.
Thanks,
Aric
Try - On Error Resume Next
-
-
Dim ctl As Control
-
For Each ctl In Me.Controls
-
ctl.Value = Null
-
Next
AricC 1,892
Recognized Expert Top Contributor
I've tried something like that but I get the error that the object doesn't support that property/method.
NeoPa 32,579
Recognized Expert Moderator MVP
If you look carefully you'll see that there is code included to avoid that situation arising (On Error Resume Next).
Try this code out as exactly as possible and let us know how you get on.
At worst you'll waste five minutes.
If it doesn't work properly for you then come back and let us know what went wrong and we'll see if we can't find another solution for you.
AricC 1,892
Recognized Expert Top Contributor
I think I got it fixed, here is the code I used, (an interesting work around): -
Private Sub ResetFields()
-
Dim ctlTextBox As Control
-
-
For Each ctlTextBox In Me.Controls
-
If TypeName(ctlTextBox) = "TextBox" Then
-
ctlTextBox.Value = Null
-
End If
-
Next ctlTextBox
-
-
-
End Sub
-
And I'm using this for combo boxes: -
For Each ctlComboBox In Me.Controls
-
If TypeName(ctlComboBox) = "ComboBox" Then
-
ctlComboBox.Value = Null
-
End If
-
Next ctlComboBox
-
NeoPa 32,579
Recognized Expert Moderator MVP
Maybe this could work better for you (similar results of course - just tidier code). - Private Sub ResetFields()
-
Dim ctlTextBox As Control
-
-
For Each ctlTextBox In Me.Controls
-
If TypeName(ctlTextBox) = "TextBox" _
-
Or TypeName(ctlTextBox) = "ComboBox" Then _
-
ctlTextBox.Value = Null
-
Next ctlTextBox
-
End Sub
PS. It would be interesting, for me as well as any future readers of the thread, if you could post what happened when you tried ADezii's code.
AricC 1,892
Recognized Expert Top Contributor
It would be interesting, for me as well as any future readers of the thread, if you could post what happened when you tried ADezii's code.
If you use this code: - Dim ctl As Control
-
For Each ctl In Me.Controls
-
ctl.Value = Null
-
Next
You will get the following Error Number: 438 Error Description: Object doesn't support this method or property.
NeoPa 32,579
Recognized Expert Moderator MVP
I understand that Aric, but that wasn't the code posted.
You left out a very important line :
which should ensure that the error is never triggered but that all controls (Text- & Combo-Boxes) that can be set to Null are (See Post #4).
AricC 1,892
Recognized Expert Top Contributor
I understand that Aric, but that wasn't the code posted.
You left out a very important line :
which should ensure that the error is never triggered but that all controls (Text- & Combo-Boxes) that can be set to Null are (See Post #4).
I didn't use that line in my testing, only the for loop. I log my errors with error handling. Sorry for the confusion.
NeoPa 32,579
Recognized Expert Moderator MVP
Not a problem Aric.
And congratulations to you for becoming a TSDN Moderator.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Yasutaka Ito |
last post by:
Hi,
As you know, all the non-ui components (like Timer control, etc.) that sit
on the form are contained in its private variable 'components'.
How can I enumerate such components from any form instance given to me? I
have no access to the source of the given form instance, but I can impose
that the form be inherited from certain base class I provide.
Would appreciate any inputs. If there is other way to access the non-ui
|
by: Jozef |
last post by:
I have some old code that I use from the Access 95 Developers handbook. The
code works very well, with the exception that it doesn't seem to recognize
wide screens, and sizes tab controls so that they are too big and wind up
covering up some of the fields on the main form.
Is there any good code out there that works in a similar fashion that will
also either a) stretch the form width wise on widescreens or b), rely on
height rather than...
|
by: Chris |
last post by:
Hi,
I'm trying to append text from another class to a generic richTextBox that
I've added to a Windows form. I can't seem to figure out how to expose the
richTextBox to append text to it.
Thanks in advance,
Chris
|
by: Jaikumar |
last post by:
Hi,
1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image.
2) In the UserControl1 i am showing one transparent form (form3) when ever user preseed left mouse button.
3) The form3 has one transparent user control (usercontrol2) that paints circles. That measn the circles will show on top the usercontrol1 image.
4) The form3 border style...
|
by: Claus Holm |
last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather
than making the menuitems public, I'd go for a public method in the parent
form to do the change, but when I call the method from the mdichild, I get
this error:
C:\MyProjects\Visual Studio Projects\Tournament\Forms\frmLogin.cs(69): The
name 'test' does not exist in the class or namespace 'Tournament.frmLogin'
frmLogin is the mdichild.
| |
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code and zipid are both passed to the lookup form/dialog by reference. I...
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code is passed to the lookup form/dialog by reference. I then load a...
|
by: John Boy |
last post by:
Hi,
Can anyone help. This is really doing my nut in. 3 years ASP exp. and
now doing .DOT which is a step in the wrong direction.
Basically I am left with the code of a guy who has left. When I click a
button on a pop-up window the javascript for that button click does a
'button.form.submit'. On the Server side there is a Button click event
for this button, but for some reason it no longer fires. It worked fine
before and everything...
|
by: ahmad.humyn |
last post by:
I want to call a hidden form. My code goes something like in which the
main calls form1. form1 has a button which creates & calls form2 and
hides itself. Now I have a button in form2 which if pressed should
dispose form2 and then unhide and focus form1.
--------------------------------------------------
static void Main()
{
.....
Application.Run(new Form1());
|
by: Toze |
last post by:
I'm using a assembly to load my apllication (ex: Mobi.exe), and now I need to
list all forms in my apllication and list all controls (ex: txtname;btnname)
inside of each form.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |