Determine Variant Data Type (wrt Hard Data Types) [Resolved]
Hi,
I am using a variant parameter in a function to simplify my UI for a control. When that funciton is called, the variant parameter will either be a string or a long. I need to determine which has been passed.
(One problem is that a string argument can begin with a number, so that rules out using the VAL function.)
(Since the argument is not an object, I cannot use the IS operator.)
How can I determine the data type of the variant within the function?
Cheers,
Nap.
Re: Determine Variant Data Type (wrt Hard Data Types)
Would this work?
VB Code:
Private Sub Form_Load()
GetType "1231ABC"
End Sub
Private Sub GetType(StrVal As Variant)
If IsNumeric(StrVal) Then
MsgBox "Is a number"
Else
MsgBox "Is a string"
End If
End Sub
Re: Determine Variant Data Type (wrt Hard Data Types)
Re: Determine Variant Data Type (wrt Hard Data Types) [Resolved]
Re: Determine Variant Data Type (wrt Hard Data Types) [Resolved]
Penagate,
I will use that one.
It covers all the core variable types that VB has.
Thanks,
Nap
Re: Determine Variant Data Type (wrt Hard Data Types) [Resolved]
I see that you took the trouble to edit your subject to add Resolved. Thanks for doing that but the easy way is to pull down the Thread Tools menu and click the Mark Thread Resolved button.
Re: Determine Variant Data Type (wrt Hard Data Types) [Resolved]
Thanks for the info. Didn't know it was there.