al4629740
asked on
break up line values to a MSFlexGrid in vb6
I have a sample output from another program in Notepad that I would like to put into an MSFlexGrid in vb6
How can I take the values in the attached sample notepad file and organize it by the spaced values?
sample.txt
How can I take the values in the attached sample notepad file and organize it by the spaced values?
sample.txt
ASKER
Thank you.
I imagine I would use a loop. When I open the notepad document, how would I start at the first line and finish on the last line within notepad.
I imagine I would use a loop. When I open the notepad document, how would I start at the first line and finish on the last line within notepad.
In Notepad save the file. I saved my copy to "C:\temp\Q_28511807.txt
Then use the code shown below. In order to get things to line up in the right columns you may have to do things like the following after line 19.
strLine = Replace(strline, "Response Sent", "Response_Sent") ' so that the two words don't get split
Then use the code shown below. In order to get things to line up in the right columns you may have to do things like the following after line 19.
strLine = Replace(strline, "Response Sent", "Response_Sent") ' so that the two words don't get split
Dim FF As Integer
Dim strParts() As String
Dim lngCol As Long
Dim strLine As String
Dim lngRow As Long
FF = FreeFile
' You may want to change the number of columns
MSFlexGrid1.Cols = 10
Open "C:\temp\Q_28511807.txt" For Input As FF
Do While Not EOF(FF)
If MSFlexGrid1.Rows >= 2 Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
End If
Line Input #FF, strLine
strParts = Split(strLine, " ")
For lngCol = 0 To UBound(strParts) - 1
MSFlexGrid1.TextMatrix(lngRow, lngCol) = strParts(lngCol)
Next
lngRow = lngRow + 1
Loop
Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Dim strParts() As String
strParts = Split(strLine, " ")
then strParts(0) will have the first section, str(1) the second, etc.