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!

split field function 1

Status
Not open for further replies.

mns117

Programmer
Apr 8, 2002
32
0
0
US
Here's the problem, thanks in advanced...

I want have a function that is sending a string to another function. basically I want to take a string, and split it...

Here's what it looks like...

11111;22222;33333

of course the length of the string between the semi colon can vary. Also I am not always sure the delimiter is going to be a semi colon. I actually get the type of delimiter from another table so that will come in to my function as a variable...

the function looks like this:

Function Actually_Parse(pFld, pdlm)
Dim val_rtnFld As String

val_rtnFld = (Left(pFld, InStr(1, pFld, pdlm) - 1))

'Actually_Parse = val_rtnFld

End Function

any ideas??




 
Hi,

How about the Split function?
Code:
dim a, i
a = split("11111;22222;33333",";")
for i = lbound(a, 1), to ubound(a, 1)
  msgbox a(i)
next
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Skip, thanks, but I get a syntax error with that code...

Is there an issue with me saying

split (pfld,dfld)

in this case pfld is a variable which contains the string that needs to be parsed, and dfld is the delimiter.
 
Try something like this:
Function Actually_Parse(pFld, pdlm)
Dim val_rtnFld As String, myArr
myArr = Split(pFld, pdlm)
val_rtnFld = myArr(0)
'Actually_Parse = val_rtnFld
End Function

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Is the Split fuction available in Access97? I don't see it?
 
Not in '97 :-(

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top