Search within String

W

W.Aarts

We've got a string (Adres) received from a database
How can I search within the string for a comma (,)?
I want to use it in the way described below
if the string contains (,) then
....
else
......

Thank you!
 
D

Doug Robbins

Use the InStr() command. Look in the VBA help file for the syntax. If what
you are searching for is not in the string it will return 0.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
K

Klaus Linke

If you need all the fields from the comma-delimited string, the easiest way would be the Split:

Dim myText As Variant, i As Long
myText = Split("a,b,c", ",")
For i = LBound(myText) To UBound(myText)
MsgBox myText(i)
Next i

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