By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

Find Using Wildcard

P: 2
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.
Mar 14 '08 #1
Share this Question
Share on Google+
5 Replies


missinglinq
Expert 2.5K+
P: 3,532
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)>

Mar 14 '08 #2

P: 2
Linq,
Thank you, it worked!
Mar 14 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Mar 14 '08 #4

NeoPa
Expert Mod 15k+
P: 31,186
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.
Mar 14 '08 #5

NeoPa
Expert Mod 15k+
P: 31,186
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"
Mar 14 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.