
Can you pass form to a module (*.bas)??
To clear ALL textboxes on a form, you could use something like...
'============
Public Sub ClearBoxes(frm As Form)
'Usage: From a form, Call ClearBoxes(Me). From anywhere, Call
ClearBoxes(FormName)
Dim iFor As Integer
Dim sTypeName As String
With frm
For iFor = 0 To .Controls.Count - 1
sTypeName = TypeName(.Controls(iFor))
If sTypeName = "TextBox" Then
.Controls(iFor).Text = ""
End If
Next iFor
End With
End Sub
'============
Or if you just want to clear specific boxes,
'============
Public Sub ClearSomeBoxes(frm As Form)
With frm
.txtThisBox.Text = ""
.txtThatBox.Text = ""
End With
End Sub
'============
Quote:
> Hello,
> I am in between a beginner and intermediate in VB6. I have 2 forms,
> frmA and frmB. Many text boxes and combo boxes on each form have the
> same name. Is there a way of calling a public function to clear the
> fields in both forms that can be viable for both forms? -If so, what
is
> it? Do I need to pass the form and how do I do that??? Thanks. A
code
> snippet and/or syntax would be greatly appreciated.
> Thank You