supergirl
07-29-2012, 08:58 AM
Hello, I have text file each field separate by ";". And I would like to
edit/move some field before upload to our system there are :-
1). move text after the first ";" to after the 2nd ";" but,
not over 50 chars.
2). if 1) length is over 50 chars move char#51 to xxx to 2nd ";"
3) move text after the 2nd ";" to after the 3rd; but, not over 50 chars.
for example
AAA company;123;abc;;10100;x;;;;1111111111;22222222;;
AAA company;;123;abc;10100;x;;;;1111111111;22222222;;
I try to develope code as below but, text some record is invalid such as
original text :-
JJJ Co., Ltd;2,4 Soi Lasal 1, Bangna,Bangna,;;;Bangkok 10260;R : Consumer Protection Sticker;;;;0105536051511;027445061;;
result text :-
JJJ Co., Ltd;;2,4 Soi Lasal 1, Bangna,Bangna,angna,2,4 Soi Lasal;angna,2,4 Soi Lasal 1, Bangna,Bangna,Bangkok 10260;2,4 Soi Lasal 1, Bangna,Bangna,Bangkok 10260;R : Consumer Protection Sticker;;;;0105536051511;027445061;;
*** seem like text after the 1st ";" is <> 50 then mid function get the first
character again til xxxx char to equal 50 chars.
For i = LBound(vData) To UBound(vData)
vChar = Split(vData(i), ";")
address = vChar(1) & vChar(2) & vChar(3)
vChar(2) = Left(address, 50) 'Address 2
vChar(3) = Left(Mid(address, 51), 50) 'Address 3
vChar(4) = vChar(4) ' Address4
vChar(1) = "" 'Address 1
objTxt.writeline (Join(vChar, "~"))
Please you suggest me how to solve it. Thank you in advances. :)
edit/move some field before upload to our system there are :-
1). move text after the first ";" to after the 2nd ";" but,
not over 50 chars.
2). if 1) length is over 50 chars move char#51 to xxx to 2nd ";"
3) move text after the 2nd ";" to after the 3rd; but, not over 50 chars.
for example
AAA company;123;abc;;10100;x;;;;1111111111;22222222;;
AAA company;;123;abc;10100;x;;;;1111111111;22222222;;
I try to develope code as below but, text some record is invalid such as
original text :-
JJJ Co., Ltd;2,4 Soi Lasal 1, Bangna,Bangna,;;;Bangkok 10260;R : Consumer Protection Sticker;;;;0105536051511;027445061;;
result text :-
JJJ Co., Ltd;;2,4 Soi Lasal 1, Bangna,Bangna,angna,2,4 Soi Lasal;angna,2,4 Soi Lasal 1, Bangna,Bangna,Bangkok 10260;2,4 Soi Lasal 1, Bangna,Bangna,Bangkok 10260;R : Consumer Protection Sticker;;;;0105536051511;027445061;;
*** seem like text after the 1st ";" is <> 50 then mid function get the first
character again til xxxx char to equal 50 chars.
For i = LBound(vData) To UBound(vData)
vChar = Split(vData(i), ";")
address = vChar(1) & vChar(2) & vChar(3)
vChar(2) = Left(address, 50) 'Address 2
vChar(3) = Left(Mid(address, 51), 50) 'Address 3
vChar(4) = vChar(4) ' Address4
vChar(1) = "" 'Address 1
objTxt.writeline (Join(vChar, "~"))
Please you suggest me how to solve it. Thank you in advances. :)