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

Help in Spliting Strings 1

Status
Not open for further replies.

aagustin

Programmer
Jul 23, 2001
12
US
I've got a field containing a person's full name separated by ".":

Doe.Jane.P

and I need to separate them into three fields: last, first, mi.

I've figure the instr function for last and first, just having problems with the middle initial part. Any help would be appreciated.

A.

 
A.

The instr is what u will need

dim s as string
dim iPos as integer
dim sSurname as string

s = "Doe.Jane.P"

iPos = instr(1,s,".")

sSurname = left$(s,ipos-1)

Nick




 
Sorry,

It should be

Dim s As String
Dim iPos As Integer
Dim sSurname As String
Dim sFirst As String
Dim iPos2 As Integer
Dim sMiddle As String

s = "Doe.Jane.P"

iPos = InStr(1, s, ".")

sSurname = Left$(s, iPos - 1)

iPos2 = InStr(iPos + 1, s, ".")

sFirst = Mid$(s, iPos + 1, iPos2 - iPos - 1)

sMiddle = Right$(s, Len(s) - iPos2)


Nick
 
Thanks Nick! Exactly what I needed. Worked great.
 
A. Agustin:

I wrote a whole VB module on splitting strings and stripping characters from strings. You can find it at:
Hope that helps. The directions should be pretty self-explanatory. I wrote this code specifically for working in an Access 97 database. You may need to add a few loop counter variables (I'm not sure why, because I tested it thouroughly, but now, coming back to it years later, I was getting an error that a variable wasn't defined, but that's an easy problem to fix!!!). Other than that, it works and works well. Check out the reviews on it if you have any doubts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top