I am struggling a little to find out how I can acheive the following:
I have saved some data to a file and from that file I need to create a report. The saved data is saved in the following format:
000123600020001201230156
I have used a text box to receive the data called txtData - this bit I have managed to accomplish. However, I need to split the data into columns under their individual field names i.e. the first 6 digits is a reference number. I am trying to use the 'SubString' method to acheive this together with the TAB function but can't get the logic right.
Here is my code:
Any ideas?
Many thanks,
Sadie
I have saved some data to a file and from that file I need to create a report. The saved data is saved in the following format:
000123600020001201230156
I have used a text box to receive the data called txtData - this bit I have managed to accomplish. However, I need to split the data into columns under their individual field names i.e. the first 6 digits is a reference number. I am trying to use the 'SubString' method to acheive this together with the TAB function but can't get the logic right.
Here is my code:
VB.NET:
Dim strText, LineOfText As String
'print data from sales file.
OpenFileDialog1.Filter "Text files (*.TXT)|*.txt"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
Try
'open file and trap any errors.
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
Do Until EOF(1)
LineOfText LineInput(1)
strText LineOfText.Substring(0, 6)
Loop
frmReport.txtData.Text strText 'read sales file to txtData.
Catch ex As Exception
MsgBox("Error opening file.")
Finally
FileClose(1)
End Try
End If
Any ideas?
Many thanks,
Sadie