seperate string into array

I have a string "strKeyAccounts" that comprised of words seperated by commas

I'd like to return set a boolean as true if another string is found within the string 'strKeyAccounts'

For example..

If strMyString = array(strKeyAccounts) then blnKeyAccount = true

I'm not too sure how I can break the string strKeyAccounts into an actual array?
antoniokingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

Use Split(strKeyAccounts, ",")


Split(strKeyAccounts, ",")(0) for the first element

Regards
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, using the split function
http://www.w3schools.com/vbscript/func_split.asp

but, you can do simpler, a one-liner:
http://www.w3schools.com/vbscript/func_instr.asp

blnKeyAccount  = instr(1, "," & strKeyAccounts & ",",  "," & strMyString & "," ) > 0
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
antoniokingAuthor Commented:
Split(strKeyAccounts, ",")(0) for the first element
The amount of elements will be changing.

blnKeyAccount  = instr(1, "," & strKeyAccounts & ",",  "," & strMyString & "," ) > 0

If strKeyAccounts = word, word2, word3
Then all this string is doing is looking for 'strMyString' in strKeyAccounts
I actually want to look for word, word2 word3 etc inside strMyString

so strKeyAccounts needs to be split into an array
0
antoniokingAuthor Commented:
Maybe I should have used Google first!
http://support.microsoft.com/kb/266289

So the code I've put together is...
strKeyAccount = Split(strKeyAccounts, ",")
   For intKeyAccountCount = LBound(strKeyAccount) To UBound(strKeyAccount)
      If InStr(1,strMyString,Trim(strKeyAccount(intKeyAccountCount)))>0 then blnKeyAccount = True
   Next intKeyAccountCount

Open in new window

0
antoniokingAuthor Commented:
Thank you gentlemen, both replies contributed to solving my issue.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.