When I am developing with Visual Basic 6, I must to make a lots procedures to manage all controls in my form. And when for the first time I was learn VB6 for the first time to disable all textbox, I'll write textbox to text, for example :
text1.Enabled=False text2.Enabled=False
text3.Enabled=False
text4.Enabled=False
and to Enable them, I have to write like this :
text1.Enabled=False
text2.Enabled=False
text3.Enabled=False
text4.Enabled=False
And I'll get trouble if textbox number is so many, so I search it on Internet and I get this trick.
To disable all textboxes I just write like this :
For Each contrl In Me.Controls
If (TypeOf contrl Is TextBox) Then
contrl.Enabled = False
End If
Next contrl
and to enable all textboxes :
For Each contrl In Me.Controls
If (TypeOf contrl Is TextBox) Then
contrl.Enabled = True
End If
Next contrl
then to reset all textboxes value :
For Each contrl In Me.Controls
If (TypeOf contrl Is TextBox) Then
contrl.Text = ""
End If
Next contrl
That's more simple than write them per textbox. And you may try to others properties.
Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts
Subscribe to:
Posts (Atom)