Passing a textbox as a function parameter

A

Alan Lambert

I'm trying to pass a textbox as a function parameter e.g.

Function IsValidData(tb As TextBox) as Boolean
'Do Stuff
End Function

but I get a "Run-time error '13': Type mismatch" error because VBA thinks I
am passing the default value.

Is there a way to do this successfully?

I'm using VBA 6.3 in Excel 2003.

Thanks in advance,

Alan
 
D

Doug Robbins

As you are using Excel, it would be better to post to an Excel newsgroup
rather than this one which is for Word.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

George Nicholson

Excel supports 2 kinds of controls: built-in and Forms.
If you are getting a type mismatch, the argument you are trying to pass
either 1) isn't a textbox, or 2) isn't the built-in type.

Function IsValidData(tb As MsForms.TextBox) as Boolean
should work if the problem is #2. If you still get a mismatch, then the
question becomes how are you calling the function?

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top