jbauer22
asked on
CASE Statement using the LIKE comparitive
I have a value stored in the first element of an array: ScriptStart(0). I want to select the case based on if the first element's string is "LIKE" one of the Cases. I don't know the proper syntax to accomplish this. Here's what I'm trying (with no luck):
Sub CaseLike()
'--- As you can see below there is no CASE for "peg_sqr2"
'--- but there is a CASE for "peg_sqr"
'--- so I need help with a LIKE statement
Dim ScriptStart(5)
ScriptStart(0) = "peg_sqr2"
Select Case ScriptStart(0)
Case Like "peg_leg*", "peg_ae*", "peg_flat*"
MsgBox "It works"
Case Like "peg_sqr*", "peg_ldg*"
MsgBox "It works"
Case Like "peg_cbl*"
MsgBox "It works"
End Select
End Sub
Sub CaseLike()
'--- As you can see below there is no CASE for "peg_sqr2"
'--- but there is a CASE for "peg_sqr"
'--- so I need help with a LIKE statement
Dim ScriptStart(5)
ScriptStart(0) = "peg_sqr2"
Select Case ScriptStart(0)
Case Like "peg_leg*", "peg_ae*", "peg_flat*"
MsgBox "It works"
Case Like "peg_sqr*", "peg_ldg*"
MsgBox "It works"
Case Like "peg_cbl*"
MsgBox "It works"
End Select
End Sub
ASKER
That's an alternative but I'd really like to know if the the LIKE comparitive can be used with CASE.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Best you will be able to do in this case will be ...
Select Case Left(ScriptStart(0), 7)
Case "peg_leg", "peg_cbl", "peg_sqr", "peg_ldg"
MsgBox "It works"
Case Else
Select Case Left(ScriptStart(0), 6)
Case "peg_ae",
Msgbox "6 Works"
Case Else
Select Case Left(ScriptStart(0), 8)
Case "peg_flat"
MsgBox "8 works"
Case Else
msgbox "Not Found
End Select
End Select
End Select
Select Case Left(ScriptStart(0), 7)
Case "peg_leg", "peg_cbl", "peg_sqr", "peg_ldg"
MsgBox "It works"
Case Else
Select Case Left(ScriptStart(0), 6)
Case "peg_ae",
Msgbox "6 Works"
Case Else
Select Case Left(ScriptStart(0), 8)
Case "peg_flat"
MsgBox "8 works"
Case Else
msgbox "Not Found
End Select
End Select
End Select
ASKER
That's what I'm talking about. Thanks! A+
if instr(1,ScriptStart(0),"pe
instr(1,ScriptStart(0),"pe
instr(1,ScriptStart(0),"pe
msgbox "It Works"
elseif ...
.
.
.
end if