|
-
Sep 23rd, 2004, 05:38 AM
#1
Thread Starter
Lively Member
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
-
Sep 25th, 2004, 02:09 PM
#2
Lively Member
this can be solved very simple like this.
make an module with the function (name doesn't mather)
something like this :
VB Code:
public function ProcessTextBox (strText as string) as string
// do something usefull with the text
ProcessTextBox = "Return some text"
End Function
and then call from the evebt you want it called from
Last edited by Calibra; Sep 25th, 2004 at 02:15 PM.
-
Sep 27th, 2004, 04:08 AM
#3
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:
public sub ProcessTextBox (TxtBox as msforms.Textbox)
TxtBox.visible = true
e.t.c !
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|