
passing a form to a module
Hi!
If you want to clear all textboxes on a form then you could place the method
in a module.
Here's an example:
Put this code in an module:
Public Sub ClearAllTxt(frm as form)
Dim Ctrl as variant
For Each Ctlr in frm.Controls
If Type Of Ctrl Is Textbox then
Ctrl.text=""
End If
next
End Sub
This method can be used with any form that needs to clear all textboxes. You
can modify this method if you want to clear other type
of controls.
I hope this helps
Happy holidays!
Regards
/Mattias Dahlgren
Quote:
>Hi there.
>I have a simple question about VisualBasic 5.0. I have a form with a few
>textboxes on it. What I want ot achieve is clearing the textboxes. This has
>to be done a few times through out the program. This is why I would like to
>place the code in a sub in module.
>The only problem is that I can't seem te be able te figure ou how I can
pass
>the form name to the sub to clear the textboxes.
>So far I've tried this, but it doesn't seem to work:
>On the form:
> Dim f As Form
> Call sClearTextboxes(f)
>In the module:
>Public Sub sClearTextboxes (f as Form)
> f.txtTextbox1.Text = ""
> f.txtTextbox2.Text = ""
>end sub
>This keeps giving me Runt-time error '91': Object variable or With block
>variable not set.
>I hope that someone can help me with this.
>Thanks,
>Eric van Glabbeek