borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Get short filename)Next Topic (DataGrid ) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Clear textboxes, Listboxes or comboboxes
Poster Message
noycez
Level: VB Guru


Registered: 14-10-2002
Posts: 79

icon Clear textboxes, Listboxes or comboboxes

hey guys, i just found an interesting code that might be helpful yo you guys in clearing all textboxes, comboboxes, listboxes in any form. just call the function. but i don't know if this code applies to other controls, havn't tried it yet.

'Declare a variable first
Dim Clear as Control

'Then put this in a module if you want the function in different forms.

Public Function ClearTxtBox(Form As Form)

   For Each Clear In Form.Controls
      If TypeOf Clear Is TextBox Then Clear.Text = ""
   Next Clear
End Function

Public Function ClearCboBox(Form As Form)
    
   For Each Clear In Form.Controls
      If TypeOf Clear Is ComboBox Then
         If Clear.Style = 2 Then
            MsgBox "Please set the Style of your ComboBox to (1- Simple Combo or 0- Dropdown Combo)"
         Else
            Clear.Text = ""
         End If
      End If

'and that's it!! you can now call the function!!

ClearTxtBox Me (Me means the current form)


    

____________________________
Funny thought:

Practice makes perfect.....
But nobody's perfect......
so why practice?

15-10-2002 at 08:14 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : Clear textboxes, Listboxes or comboboxes
Previous Topic (Get short filename)Next Topic (DataGrid ) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder