Board index » Visual Studio » What's the command to detect the data type of a variable?

What's the command to detect the data type of a variable?

Visual Studio167
Hi Gang,

I would like to know what function returns the data type of a particular

variable. I'm already familiar with isArray, but haven't had much

experience with the function that returns the data type. Can somebody

provide an example following this template:

-------------------------------------------

If ?(strWhatever) = "String" Then

etc...

End if

-------------------------------------------

Thanks a bundle,

Christian Blackburn


-
 

Re:What's the command to detect the data type of a variable?

Quote
I would like to know what function returns the data type of a particular

variable. I'm already familiar with isArray, but haven't had much

experience with the function that returns the data type. Can somebody

provide an example following this template:

-------------------------------------------

If ?(strWhatever) = "String" Then

etc...

End if

-------------------------------------------



Look up VarType Function in the help files (in order to see the lengthy list

of possible return values).



Rick - MVP





-

Re:What's the command to detect the data type of a variable?

In addition to TypeName and VarType, there's also the TypeOf

statement, which works for object types. For instance:



If TypeOf theObjRef Is Form Then

MsgBox "Hey, I'm a Form"

End If





+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

Monte Hansen - MVP VB

KillerVB.com">KillerVB.com

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+



"Christian Blackburn" <Christian@Damn@Spam@Hotmail.com>wrote in

message news:euu4uUIZDHA.384@TK2MSFTNGP12.phx.gbl...

Quote
Hi Gang,

I would like to know what function returns the data type of a

particular

variable. I'm already familiar with isArray, but haven't had much

experience with the function that returns the data type. Can

somebody

provide an example following this template:

-------------------------------------------

If ?(strWhatever) = "String" Then

etc...

End if

-------------------------------------------

Thanks a bundle,

Christian Blackburn







-

Re:What's the command to detect the data type of a variable?

Dear Rick, Eduardo, and Monte,

Thank you all very much for the hell I'll research these function they all

will undoubtedly be of use to me.

Cheers,

Christian





"Monte Hansen" <monte@nospam.com>wrote in message

Quote
In addition to TypeName and VarType, there's also the TypeOf

statement, which works for object types. For instance:



If TypeOf theObjRef Is Form Then

MsgBox "Hey, I'm a Form"

End If





+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

Monte Hansen - MVP VB

KillerVB.com">KillerVB.com

+|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+



"Christian Blackburn" <Christian@Damn@Spam@Hotmail.com>wrote in

message news:euu4uUIZDHA.384@TK2MSFTNGP12.phx.gbl...

>Hi Gang,

>I would like to know what function returns the data type of a

particular

>variable. I'm already familiar with isArray, but haven't had much

>experience with the function that returns the data type. Can

somebody

>provide an example following this template:

>-------------------------------------------

>If ?(strWhatever) = "String" Then

>etc...

>End if

>-------------------------------------------

>Thanks a bundle,

>Christian Blackburn

>

>







-