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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return character position in string 1

Status
Not open for further replies.

rwttm001

IS-IT--Management
Nov 20, 2002
26
GB
Hi all

I would appreciate some help in returning the location within a string of both ( and ), which ultimately will help me write a procedure around the Mid function to return the value between the brackets.

So basically I need the position within a string of the first instance of a certain character...

Thanks

MWR
 
Hello,

Could it be something like this?

InStr (Función)


Devuelve un tipo Variant (Long) que especifica la posición de la primera aparición de una cadena en otra.

Sintaxis

InStr([start, ]string1, string2[, compare])


I hope this will help you...
 
Sorry, I'm spanish, so the help in access is in spanish...

The function returns a Long with the position of the first instance of the first string into the second...
 
There's also InstrRev which is basically the same thing but starts looking from the end of the source string.

Apparently only available from VB6 so it may not be available depending on the application you're using.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
To get a string from within brackets in VBA:
stPos = instr(string1,"(")
enPos = instr(stPos,string1,")")
mStr = mid(string1,stPos,EnPos-StPos)

or similar

Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Thanks xlbo

That's exactly what I wanted.

I think everyone else was under the impression I was looking for a set string, rather than trying to return the string from within the brackets.

MWR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top