Connecting Tech Pros Worldwide Forums | Help | Site Map

Find Using Wildcard

Newbie
 
Join Date: Mar 2008
Posts: 2
#1: Mar 14 '08
Hi, I am very new to visual basic and am using a select case statement with something called fSort. I found the code on a website but I need to modify it a little. I have a phrase and want to replace it with another phrase kind of like a Find and Replace tool. I have:

Case "doesn't exist in Boston", "doesn't exist in New York", "doesn't exist in Atlanta"
fSort = "doesn't exist"

but there are a ton more cities I want to include in the case statement so instead of typing one long case statement I want to know if I can use a wild card or wild character to replace the city name. For instance:

Case "doesn't exist in *wildcard*"
fSort = "doesn't exitst"

Can I do something like that?
Thanks.

missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,103
#2: Mar 14 '08

re: Find Using Wildcard


Gemini1617, if you're saying that regardless of the city name, you want fSort to equal "doesn't exist" if the beginning of your field is "doesn't exist in" then, assuming the textbox holding this phrase is YourTextBox, you can use the example NeoPa just posted.

Expand|Select|Wrap|Line Numbers
  1. Select Case True
  2.   Case  Left(Me.YourTextBox,16) = "doesn't exist in"
  3.     fSort = "doesn't exist"
  4. End Select
Welcome to TheScripts!

Linq ;0)>

Newbie
 
Join Date: Mar 2008
Posts: 2
#3: Mar 14 '08

re: Find Using Wildcard


Linq,
Thank you, it worked!
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,103
#4: Mar 14 '08

re: Find Using Wildcard


Glad we could help!

Linq ;0)>
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#5: Mar 15 '08

re: Find Using Wildcard


Gemini,

Welcome to TheScripts, but please don't post your question in somebody else's thread in future.

I have split this away from Understanding the Select Case Statement and into its own thread now.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#6: Mar 15 '08

re: Find Using Wildcard


Remember too, a Select Case statement is only warranted if you have multiple situations to handle. If you simply want to execute the logic you mention, you can use :
Expand|Select|Wrap|Line Numbers
  1. If LCase(Left(YourTextBox, 17)) = "doesn't exist in " Then _
  2.     fSort = "doesn't exist"
Reply