Results 1 to 3 of 3

Thread: what kind of arguments are needed when i try to pass textbox from a sub to another

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71

    what kind of arguments are needed when i try to pass textbox from a sub to another

    I have a project with many form, on this forms a textbox is coming back again and again, so i try to put the code of this textbox on a public sub, but it is not working it says object doesn't exist.

    so i try to declare the textbox in the argument list with the sub name but the call fonction is not working why

    see details here

  2. #2
    Lively Member
    Join Date
    Sep 2004
    Posts
    74
    this can be solved very simple like this.

    make an module with the function (name doesn't mather)

    something like this :
    VB Code:
    1. public function ProcessTextBox (strText as string) as string
    2.  
    3.     // do something usefull with the text
    4.  
    5. ProcessTextBox = "Return some text"
    6. End Function

    and then call from the evebt you want it called from
    Last edited by Calibra; Sep 25th, 2004 at 02:15 PM.

  3. #3
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657
    Writelearner actually want to pass a Textbox into a function not just some text, so he can change some of the attributes of the textbox itself, i.e Visibilty.

    Like i said in Writelearners other post, Excel VBA has 2 type libaries for some common contols such as Textboxs & comboboxs e.t.c ,

    so when declaring a Textbox in Excel VBA you have to prefix it with the correct library.

    VB Code:
    1. public sub ProcessTextBox (TxtBox as msforms.Textbox)
    2.  
    3.   TxtBox.visible = true  
    4.  
    5.   e.t.c !
    6.  
    7. End sub

    The problem i had when trying to convey this before was if you leave out the "msforms" type library prefix you get a "Type 13 Type Mismatch"

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