Solved

Help with partial string search using Substring

Posted on 2014-02-20
5
262 Views
Last Modified: 2014-02-20
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
0
Comment
Question by:vcharles
  • 3
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39874177
Use the Like operator

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

Expert Comment

by:mankowitz
ID: 39874183
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
 

Author Comment

by:vcharles
ID: 39874395
Thank You for both answers, I will get back to you.

Victor
0
 

Author Comment

by:vcharles
ID: 39875104
Hi,

I was able to solve the issue withthe code below.

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


Thanks,

Victor
0
 

Author Closing Comment

by:vcharles
ID: 39875105
Thank You.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now