Hi,
I receive a csv file from a client that needs to have the data split into text boxes on a form. I have had this working for ages and now the client has changed the format of the csv file.
it used to come with multiple rows of data and each row was seperated by commas.
Now it comes as a single line of data and has vblf defining were the rows are and then each of the rows are seperated by commas again.
here is the code that was working but does not like the vblf now.
Could anyone help me please as i can't seem to be able to work out what needs changing.
regards
I receive a csv file from a client that needs to have the data split into text boxes on a form. I have had this working for ages and now the client has changed the format of the csv file.
it used to come with multiple rows of data and each row was seperated by commas.
Now it comes as a single line of data and has vblf defining were the rows are and then each of the rows are seperated by commas again.
here is the code that was working but does not like the vblf now.
Code:
strPath = sPath
strFile = HoldName
strFile = Dir(strPath & strFile)
Do While strFile <> ""
Open strPath & strFile For Input As #1
On Error GoTo errorhandler
Do
ReDim Preserve RowData(x)
Line Input #1, strData
RowData(x) = strData
strData = vbNullString
x = x + 1
Loop Until EOF(1)
UpDown1.Max = UBound(RowData)
UpDown1.Min = LBound(RowData) + 2
Dim ColData() As String
ColData = Split(RowData(2), ",")
For i = 0 To UBound(ColData)
Text1(i).Text = ColData(i)
Next i
Close #1
strFile = Dir
Loop
Text2.Text = recordNo + 1
Text3.Text = UBound(RowData) - 1
Exit Sub
errorhandler:
MsgBox "Failed to open record. Please check the report file from Welcome.", vbCritical, "Critcal Error"
End Sub
Function populate(iIndex As Integer)
On Error Resume Next
Dim ColData() As String
ColData = Split(RowData(iIndex), ",")
For i = 0 To UBound(ColData)
Text1(i).Text = ColData(i)
Next i
End Function
Could anyone help me please as i can't seem to be able to work out what needs changing.
regards