Usually Passing Form Name I use the code:
Private Sub Test1
Test2(me)
End Sub
Private Sub Test2(FormName as Form)
FormName.Unload
End Sub
But How Do I pass the TextBox Control Name to another Sub/Function?
Please help..
Printable View
Usually Passing Form Name I use the code:
Private Sub Test1
Test2(me)
End Sub
Private Sub Test2(FormName as Form)
FormName.Unload
End Sub
But How Do I pass the TextBox Control Name to another Sub/Function?
Please help..
you just declare the argument as a TextBox
ex.
Private Sub Text1_GotFocus()
MarkText Text1
End Sub
Private Sub MarkText(tb As TextBox)
tb.SelStart = 0
tb.SelLength = Len(tb.Text)
End Sub
My problem is I try to pass the form name And textbox name to a Module outside the original program.
Private Sub Text1_GotFocus()
MarkText Me,Text1
End Sub
Private Sub MarkText(fm As Form ,tb As TextBox)
fm.tb.SelStart = 0
fm.tb.SelLength = Len(tb.Text)
End Sub
This will give me an error. But If I remove the fm..
tb.SelStart = 0
tb.SelLength = Len(tb.Text)
The code will run smoothly..
Why do you want to pass the formnamne to a sub that is going to handle a control?
Hi, tomtan! :)
Your problem seems to be: you have been passing the name of a form to a procedure which then takes some action upon it. Now you want to pass the name of a textbox control which is on a form to that procedure which will take action upon the textbox control, right?
If yes, then remember this: if you pass the textbox control to the procedure, you don't have to pass the form name to it. The TextBox.Parent Property will give the procedure the name of the form in which the textbox is.
Hi HoneyBee,
Thanks for the information..
[Edited by tomtan on 07-28-2000 at 10:24 PM]
Even then, you don't need the form name. Just accept the name of the text box into the procedure and proceed with it. It should work fine.