Chris_871 Level: Master

 Registered: 30-11-2002 Posts: 106
|
Clear Textboxes Using For Each and Typeof in VB.Net
Hi Friends
We can able to clear textboxes(Other controls also)in VB.Net
like VB. but u have to make slight changes.
Create one window form and place one Groupbox control and keep some textboxes inside the groupbox.
Now write the following code.
Public Sub cleartext(ByVal frm As Form)
Dim ctrl1, ctrl2 As Control
For Each ctrl1 In frm.Controls
If TypeOf ctrl1 Is GroupBox Then
For Each ctrl2 In ctrl1.Controls
If TypeOf ctrl2 Is TextBox Then
ctrl2.Text = ""
End If
Next
End If
Next
End Sub
Now u can call the procedure by passing the form object.
by
Chris
[Edited by Chris_871 on 20-09-2003 at 12:26 AM GMT]
[Edited by Chris_871 on 21-11-2003 at 10:07 AM GMT]
|