string parsing help

  • Thread starter Thread starter KS
  • Start date Start date
K

KS

I have a text string like so:

SK139044GP4@SK139044GP7@SK139044GR0UP4@SK139044PC7@506386@

I need a fucntion to pull "SK139044GR0UP4", the 3rd text
string after the second occurrence of @.

please send response to:

(e-mail address removed)

Thank you
 
What version of Access? If it's Access 2000 or higher, you can use the
built-in Split function:

Dim strTextString as String
Dim varValues As Variant

strTextString = "
SK139044GP4@SK139044GP7@SK139044GR0UP4@SK139044PC7@506386@ "
varValues = Split(strTextString, "@")

Now, varValues(0) will be SK139044GP4, varValues(1) will be SK139044GP7,
varValues(2) will be SK139044GR0UP4 and so on.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



KS said:
I have a text string like so:

SK139044GP4@SK139044GP7@SK139044GR0UP4@SK139044PC7@506386@

I need a fucntion to pull "SK139044GR0UP4", the 3rd text
string after the second occurrence of @.

please send response to:

(e-mail address removed)

Uh uh. When you post your question in a newsgroup, you come back to the
newsgroup to get the answer.
 
-----Original Message-----
What version of Access? If it's Access 2000 or higher, you can use the
built-in Split function:

Dim strTextString as String
Dim varValues As Variant

strTextString = "
SK139044GP4@SK139044GP7@SK139044GR0UP4@SK139044PC7@506386@ "
varValues = Split(strTextString, "@")

Now, varValues(0) will be SK139044GP4, varValues(1) will be SK139044GP7,
varValues(2) will be SK139044GR0UP4 and so on.

-- varValues returned "EMPTY"
 
In a module:

Sub TestSplit()
Dim lngLoop As Long
Dim strTextString As String
Dim varValues As Variant

strTextString =
"SK139044GP4@SK139044GP7@SK139044GR0UP4@SK139044PC7@506386@"
varValues = Split(strTextString, "@")

For lngLoop = LBound(varValues) To UBound(varValues)
Debug.Print "varValues(" & lngLoop & ") = " & varValues(lngLoop)
Next lngLoop

End Sub

In the Debug window:

TestSplit
varValues(0) = SK139044GP4
varValues(1) = SK139044GP7
varValues(2) = SK139044GR0UP4
varValues(3) = SK139044PC7
varValues(4) = 506386
varValues(5) =
 
Back
Top