Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a substring (string within a string)

Status
Not open for further replies.

LTillner

MIS
Apr 23, 2002
96
US

I want to find a substring or a string within a string
and use that substring as a variable.

this is the data that I need to parse:

3 ELA ApS T3
3 MA ApS T6
4 ELA Bsk T7
4 ELA ApS T5
5 SC ApS T8
10 ELA Aps T1
10 ELA Bsk T2
10 MA Aps T1

So the problems for me are:
1 -- what is the VBA function for substr -- substring??
InStr??
what I would write in Visual FoxPro is
Substr(mydatafield,1,2)="10"
that would read find the substring in mydatafield beginning with the 1st position for 2 positions. and see if it equals "10"

How would I write that in VBA????

I want to do an if statment (or a case statement) that says if ELA then something, ELSEIF MA then something else ELSE SC then something different.

Thanks!

 
Use the mid function.

Ex...

mid(mydatafield, 1, 2)

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks, got it. Why the heck is it called "MID" like for Middle? that makes no sense to me!
 
LTilner

have a looka the Case if statements they do what you are looking for oj the multi if statments part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top