Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Statement 1

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
Can you help me with the below case statement? TextString is the variable, and I am looking for the letters OPT. If they exist, cI want to continue, if they don't i want to stop.

Select Case TextString
Case "OPT" 'if it doesn't contain OPT, quit

GoTo Continue
Case Else ' Other values.
GoTo Quits
End Select

Thankyou
 
You don't want CASE, just an If-then-else e.g.
Code:
If InStr(1, TextString, "OPT", vbTextCompare) > 0 Then
    'Contains OPT
Else
    'Doesn't contain OPT
End If
Your CASE statement doesn't work as it's looking for an exact match with OPT, rather than just containing OPT.

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top