|
-
Mar 13th, 2012, 02:49 AM
#1
Thread Starter
Lively Member
[RESOLVED] VB6 & Reading CSV file with data including spaces
Greetings
I am reading csv file with below code;
SAMPLE INPUT FILE:
AAAA,43438894322,USA,BASIC
BBBB,73738 9393 939,INDIA,BASIC
CCCC,00293993020,UK,PREMIUM
all is well until i get any file with data having space like
01 0002 020929
65650002 543
Code:
connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Path & ";Extended Properties='text;HDR=" & hasHeader & ";FMT=Delimited'"
rsCSV.Open "Select * From " & fileName, _
connCSV, adOpenStatic, adLockReadOnly, adCmdText
Do While Not rsCSV.EOF()
cntRows = cntRows + 1
With MSFlexGrid1
currRow = .Rows - 1
.TextMatrix(currRow, 1) = rsCSV.Fields(0).Value
.TextMatrix(currRow, 2) = rsCSV.Fields(1).Value
.TextMatrix(currRow, 3) = Format(rsCSV.Fields(2).Value, "####.000")
.TextMatrix(currRow, 4) = PadRight(Left(rsCSV.Fields(3).Value, 8), "XXXXXXXX")
If Len(Trim(rsCSV.Fields(4).Value)) = 0 Then .TextMatrix(currRow, 5) = "" Else .TextMatrix(currRow, 5) = rsCSV.Fields(4).Value
.TextMatrix(currRow, 6) = rsCSV.Fields(5).Value
.TextMatrix(currRow, 7) = rsCSV.Fields(6).Value
.Rows = .Rows + 1
End With
rsCSV.MoveNext
Loop
Your help will be highly appreciated,
Thanks
Sam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|