Click to See Complete Forum and Search --> : cut string in parts (before and after comma)


gerjanschoemake
09-16-2005, 06:31 AM
Hello,

I have a DB which contains the following values:

L,P3/UR
T1/UR
L,P3,S2/UR
L,P1,T2/UR

I would like the following:
If it contains no comma
value1 = value before slash
If it contains 1 comma
value1 = value before comma, untill the slash
value2 = value after comma, untill the slash
if it contains two comma's
value1 = value before first comma, untill the slash
value2 = value before second comma, untill the slash
value3 = value after second comma, untill the slash

tnx!
Gerjan

slyfox
09-17-2005, 08:12 AM
Split the data into arrays, then use the 1st,2nd or 3rd array...

if it's commas and slashes, then split it first with the slashes and then with the commas.

Bullschmidt
09-20-2005, 02:59 PM
And here's a related link:

Parsing with join and split - 5/9/1999
http://www.4guysfromrolla.com/webtech/050999-1.shtml

gerjanschoemake
09-21-2005, 02:49 AM
Tnx,

I already had found a tutorial and have done it like this:

'Eerste split, slash
myArraySlash = Split(drukcode,"/")

'Tweede split, komma
myArraycomma = Split(myArraySlash(0),",")

printnumber = 0
For i = LBound(myArraycomma) TO UBound(myArraycomma)
printnumber = printnumber+1
Next

if printnumber > 0 then
meth1 = myArraycomma(0)
end if

if printnumber > 1 then
meth2 = myArraycomma(1)
end if

if printnumber > 2 then
meth3 = myArraycomma(2)
end if