Stapman
asked on
If with Variant-type
I have a Variant type which can become to an Integer, a String a Null in my Sub.
I use "If 'variable' Then" and go over the "else" statement to run the source code in case of my 'variable' being "Null".
This works good when 'variable' is an integer - the "if"-clause is "true" - but when 'variable' is a string the error #13 arises (type problem...).
Thanks for your support!
I use "If 'variable' Then" and go over the "else" statement to run the source code in case of my 'variable' being "Null".
This works good when 'variable' is an integer - the "if"-clause is "true" - but when 'variable' is a string the error #13 arises (type problem...).
Thanks for your support!
Stapman,
I'm not sure that I have understood you correctly. Here is an attempt, though. There is an IsNull function that may help. You can also try the IsEmpty function that returns True if the variant variable has not been assigned a value.
If IsNull(x) Then ...
Ture Magnusson
Karlstad, Sweden
I'm not sure that I have understood you correctly. Here is an attempt, though. There is an IsNull function that may help. You can also try the IsEmpty function that returns True if the variant variable has not been assigned a value.
If IsNull(x) Then ...
Ture Magnusson
Karlstad, Sweden
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim Condition As Variant
Condition = 1
If Condition Then MsgBox "True"
Condition = "1"
If CInt(Condition) Then MsgBox "True"
Condition = Null
If IsNull(Condition) Then MsgBox "True"
Condition = 1
If Condition Then MsgBox "True"
Condition = "1"
If CInt(Condition) Then MsgBox "True"
Condition = Null
If IsNull(Condition) Then MsgBox "True"
ASKER
Thanks for your quick and detailed answer(s). Thanks to SLE too!
ASKER