noycez Level: VB Guru

 Registered: 14-10-2002 Posts: 79
|
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?
|