Using "Like" in Select Case Statements

  • Thread starter Microsoft Newsgroups
  • Start date
M

Microsoft Newsgroups

Is it possible to use "Like" in a Select Case, such as,

Select Case Variable
Case Like "*jones"

How is this done?
 
K

Klaus Linke

Is it possible to use "Like" in a Select Case, such as,
Select Case Variable
Case Like "*jones"

How is this done?

According to the help, "Like" and "Is" can't be used as comparison operators
in "Select Case" statements.

If you want to avoid complicated "If" structures, you might perhaps use
Switch to set some variable, and then use "Select Case" with that:

myTestVar = Switch( _
myVar Like "*jones", "ends_with_jones", _
myVar Like "*smith", "ends_with_smith", _
myVar Like "*miller", "ends_with_miller")

Select Case myTestVar
Case "ends_with_jones"
...

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top