How to determine type of function argument?

N

nomail1983

Sigh, I left my VBA programming book at home.

How do I determine the type of a function argument?

For example, I want to the following (pseudocode):

function myfunc(arg)
if arg type is Range then
blah blah
end if
end function

Moreover, how do I determine all the values that "arg type" can be?

For example, I want to the following (pseudocode):

function myfunc(arg)
select case arg type
case Range
blah blah
case This
blah blah
case That
blah blah
end select

I need to know all the possible cases.
 
B

Bob Phillips

Function myfunc(arg)
Select Case TypeName(arg)
Case "Range": MsgBox "Range"
Case "String": MsgBox "String"
Case "Double": MsgBox "Double"
Case Else: MsgBox TypeName(arg)
End Select
End Function

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
N

nomail1983

Case Else: MsgBox TypeName(arg)

Ding! Perfect. Thanks.

I had tried Type(arg), to no avail of course. Then I got distracted
when my inept Help search technique turned up the Type and DataType
properties -- which, of course, steered me in the wrong direction.
Klunk!

So I'm in the VBA editor, and I just cannot remember the name of some
VBA function. How can I get a list of all VBA functions?

Coulda sworn there is a way.

Anyway, thank again.
 
T

Tom Ogilvy

Look in the object browser

Select VBA as the library.

then look at the classes and members
 

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