Message 1 of 3
why don't constants work in select case?

Not applicable
01-04-2002
03:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
am I not supposed to be able to use VarType constants to test with a select
case
or am I just doing it wrong?
considering the following:
Sub TESTCASE()
Dim TESTARRAY(0 To 2) As Variant
Dim ARRAY2(2) As Integer '(or string or double or variant)
Dim I As Integer
TESTARRAY(0) = "STRING"
TESTARRAY(1) = 2
TESTARRAY(2) = ARRAY2
For I = LBound(TESTARRAY) To UBound(TESTARRAY)
Debug.Print VarType(TESTARRAY(I))
Select Case VarType(TESTARRAY(I))
''''''''''this works
Case Is = vbString
Debug.Print "case is vbstring"
'''''''this doesn't
'Case Is = vbDouble
''''''''''this works
Case Is = 2
Debug.Print "case is vbDouble"
'''''''this doesn't
Case Is = vbArray
Debug.Print "case is vbArray"
End Select
Next I
End Sub
questions:
(a) why is vbString the only constant that works?
(b) help for VarType Constants says the constant vbArray = 8192
but I get from debug.print vartype(var):
8197 for ar() as double
8204 for ar() as variant
8194 for ar() as integer
8200 for ar() as string
what secret mystery am i missing out on?
anyone care to clue me in?
Thanks
Mark
am I not supposed to be able to use VarType constants to test with a select
case
or am I just doing it wrong?
considering the following:
Sub TESTCASE()
Dim TESTARRAY(0 To 2) As Variant
Dim ARRAY2(2) As Integer '(or string or double or variant)
Dim I As Integer
TESTARRAY(0) = "STRING"
TESTARRAY(1) = 2
TESTARRAY(2) = ARRAY2
For I = LBound(TESTARRAY) To UBound(TESTARRAY)
Debug.Print VarType(TESTARRAY(I))
Select Case VarType(TESTARRAY(I))
''''''''''this works
Case Is = vbString
Debug.Print "case is vbstring"
'''''''this doesn't
'Case Is = vbDouble
''''''''''this works
Case Is = 2
Debug.Print "case is vbDouble"
'''''''this doesn't
Case Is = vbArray
Debug.Print "case is vbArray"
End Select
Next I
End Sub
questions:
(a) why is vbString the only constant that works?
(b) help for VarType Constants says the constant vbArray = 8192
but I get from debug.print vartype(var):
8197 for ar() as double
8204 for ar() as variant
8194 for ar() as integer
8200 for ar() as string
what secret mystery am i missing out on?
anyone care to clue me in?
Thanks
Mark