Help with partial string search using Substring

Hi,


How do you modify the Substring below which searches for the first three characters in a field to search for part of the data in a data field,

For example if the field contains 9999-00-999-9999 Ho do I search only for 00, considering xyz '''00'".

Dim SearchCriteria as String = "Substring(SN, 1,3) IN ('" & xyz &"')

Thanks,

Victor
vcharlesAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Use the Like operator

Dim SearchCriteria as String = "SN LIKE '%" & xyz &"%'"
0
 
mankowitzCommented:
I think what you are saying is that if you have a field like

9999-00-999-9999

You want to search against the 6-7th characters instead of the 1-3rd characters, right?

Dim SearchCriteria as String = "Substring(SN, 6,2) IN ('" & xyz &"')
0
 
vcharlesAuthor Commented:
Thank You for both answers, I will get back to you.

Victor
0
 
vcharlesAuthor Commented:
Hi,

I was able to solve the issue withthe code below.

Dim SearchCriteria as String = "SN LIKE '%" & xyz &"%'"


Thanks,

Victor
0
 
vcharlesAuthor Commented:
Thank You.
0
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.

All Courses

From novice to tech pro — start learning today.