PDA

View Full Version : Solved: help optimizing case select



Gtrain
06-28-2008, 05:51 PM
Guys,

just wondering if someone can shed some light on adding a wildcard to my case statement

Select Case comment
Case "NO TRAIN"
status1(UBound(Comments)) = 8
Case "NO TRAIN IN"
status1(UBound(Comments)) = 8
Case "NO TRAIN TO LOAD"
status1(UBound(Comments)) = 8
Case "WAIT FOR TRAIN"
status1(UBound(Comments)) = 8
Case "FINISHED TRAIN"
status1(UBound(Comments)) = 8
Case "TRAIN FINISHED"
status1(UBound(Comments)) = 8
Case "TRAIN BROKE DOWN"
status1(UBound(Comments)) = 8
End Select

I would like to case anything with train, but not training if possible

something like Case "*"&"TRAIN"&"*"
status1(UBound(Comments)) = 8

just drawing a blank. hopefully this is enough info!

mikerickson
06-28-2008, 10:13 PM
If (comment Like "*TRAIN *") Or (comment Like "*TRAIN") Then status1(UBound(Comments)) = 8

Or perhaps this, note that "TRAININ" fails the test.
If (comment & "xyz" Like "*TRAIN[!I][!N][!G]*") Then

Bob Phillips
06-29-2008, 02:36 AM
KISS


If (comment Like "*TRAIN*") And (comment <> "TRAINING")

Gtrain
07-01-2008, 01:56 AM
Thanks guys, wasn't thinking like that at all, Idiot!

after that i decided to run with

If (comment Like "*TRAIN*") Or (comment Like "*TRIAN*") And (comment <> "TRAINING") Then
status1(UBound(Comments)) = 8

just for some people that have trouble spelling :rotlaugh: !

Thanks

G

marshybid
07-01-2008, 05:16 AM
Thanks guys, wasn't thinking like that at all, Idiot!

after that i decided to run with

If (comment Like "*TRAIN*") Or (comment Like "*TRIAN*") And (comment <> "TRAINING") Then
status1(UBound(Comments)) = 8

just for some people that have trouble spelling :rotlaugh: !

Thanks

G
You could also have modified the code sent in by xld to read


If (comment Like "*TR*") And (comment <> "TRAINING")


That would take spelling innaccuracies into account too.

Marshybid