Steve Lim
asked on
Splitting a string from CSV file by comma delimited
Hi All,
Have a problem and need help here. i am using vb6 and now face 2 problem .
1. Need to split the string into variable from CSV file but the data may contain comma in quote, which is -
- string = abc,"3,4,5,6","3",Steve,go t,"1,2,3", problem
* i want to split into 6 variable to become
aVar = "abc"
bVar = "3,4,5,6"
cVar = "3"
dVar = "Steve"
eVar = "got"
fVar = "1,2,3"
gVar = "problem"
2. i want to sort the string in 2 element, which is sort bVar then follow by fVar.
Anyone able to advice,
thanks in advance.
Regards
Steve
Have a problem and need help here. i am using vb6 and now face 2 problem .
1. Need to split the string into variable from CSV file but the data may contain comma in quote, which is -
- string = abc,"3,4,5,6","3",Steve,go
* i want to split into 6 variable to become
aVar = "abc"
bVar = "3,4,5,6"
cVar = "3"
dVar = "Steve"
eVar = "got"
fVar = "1,2,3"
gVar = "problem"
2. i want to sort the string in 2 element, which is sort bVar then follow by fVar.
Anyone able to advice,
thanks in advance.
Regards
Steve
ASKER
Thanks Ryan but i try to using split function but the problem is the comma in quote.
Private Sub Command1_Click()
Dim myStr As String
Dim xPos As Integer
myStr = "This:is:a:test:string"
xPos = InStr(1, myStr, ":")
Debug.Print Mid$(myStr, 1, xPos - 1)
Debug.Print Mid$(myStr, xPos + 1, Len(myStr))
I programmed vb6 back in 1999 this worked then :-)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi Ryan,
got it
got it
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi All,
Thanks alot and appreaciate all the advice and guide, due to the project is in rush, i using a stupid method to do it and finally i have done what i want.
Regards
Steve
Thanks alot and appreaciate all the advice and guide, due to the project is in rush, i using a stupid method to do it and finally i have done what i want.
Regards
Steve
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I have recommended this question be closed as follows:
Split:
-- aikimark (https:#a42180666)
-- aikimark (https:#a42180575)
-- GrahamSkan (https:#a42180168)
-- Ryan Chong (https:#a42179336)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
MacroShadow
Experts-Exchange Cleanup Volunteer
I have recommended this question be closed as follows:
Split:
-- aikimark (https:#a42180666)
-- aikimark (https:#a42180575)
-- GrahamSkan (https:#a42180168)
-- Ryan Chong (https:#a42179336)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
MacroShadow
Experts-Exchange Cleanup Volunteer
and then doing a loop to compare the values and sort accordingly (this depends on your logic of sorting).