Results 1 to 7 of 7

Thread: Passing TextBox Control Name????

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    39

    Question

    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..
    ThOmaS TaN

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    39
    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..
    ThOmaS TaN

  4. #4
    Guest
    Why do you want to pass the formnamne to a sub that is going to handle a control?

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    39

    Talking

    Hi HoneyBee,

    Thanks for the information..


    [Edited by tomtan on 07-28-2000 at 10:24 PM]
    ThOmaS TaN

  7. #7
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width