Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Using "Like" in Select Case Statements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Microsoft Newsgroups - 09 Jan 2007 03:10 GMT
Is it possible to use "Like" in a Select Case, such as,

Select Case Variable
   Case Like "*jones"

How is this done?
Klaus Linke - 09 Jan 2007 03:47 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.