|
-
Jul 28th, 2000, 03:19 AM
#1
Thread Starter
Member
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..
-
Jul 28th, 2000, 03:26 AM
#2
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
-
Jul 28th, 2000, 03:45 AM
#3
Thread Starter
Member
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..
-
Jul 28th, 2000, 04:02 AM
#4
Why do you want to pass the formnamne to a sub that is going to handle a control?
-
Jul 28th, 2000, 05:01 AM
#5
Well ....
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.
-
Jul 28th, 2000, 08:05 PM
#6
Thread Starter
Member
Hi HoneyBee,
Thanks for the information..
[Edited by tomtan on 07-28-2000 at 10:24 PM]
-
Jul 28th, 2000, 09:26 PM
#7
Well ....
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|