cfisher440
Well-known member
- Joined
- Oct 11, 2005
- Messages
- 73
- Programming Experience
- 1-3
I am driving myself crazy attempting to come up with a function that will do this. I am trying to parse a line. Easy enough of a task, but the lines look like this.
Notice that
1.) the integers and time values are spaced apart at different lengths from each other (with the use of spaces (as opposed to tabs)).
2.) all lines are formatted like this (but where there is a value like 6, there could be a 23 (a tens value as oppossed to a ones value).
I have come across a function that will recieve the integer values out of a line of text, but for some reason it won't extract the time values correctly.
Here is the function:
I have also used the regex.split function, which works nicely, but haven't found a way to make it work in this case when the lines will vary a lot with different values (some values being ones, some tens, etc..).
Any ideas for how to get the values of these line or how to adjust the function to do so, I would appreciate it.
VB.NET:
013 11:08 62 1 6 6 1 04:09 00:01 05:08 01:25 02:20 1.0 55.3
020 08:21 31 0 1 0 0 11:22 02:00 00:00 07:34 00:00 4.0 11.2
Notice that
1.) the integers and time values are spaced apart at different lengths from each other (with the use of spaces (as opposed to tabs)).
2.) all lines are formatted like this (but where there is a value like 6, there could be a 23 (a tens value as oppossed to a ones value).
I have come across a function that will recieve the integer values out of a line of text, but for some reason it won't extract the time values correctly.
Here is the function:
VB.NET:
Private Function GetData(ByVal LineOfText As String, ByVal DataNumber As Int16) As String
'*********************************************************************************************
'*** Feed the function a line of text as a string.
'*** and feed it a number. It will return the word within the sentence.
'*** Ex:
'*** This is a line of text
'*** if that line of text was a string named test and I fed the function test and 1 I would
'*** recieve the second word of the sentence. Thus, the value returned will be "is".
'*********************************************************************************************
Dim currNumber As Int16 = -1
Dim sData As String
Dim blnSpaces As Boolean
For i As Int16 = 0 To LineOfText.Length - 1
If LineOfText.Chars(i) = " " And blnSpaces = False Then
blnSpaces = True
ElseIf LineOfText.Chars(i) = " " And blnSpaces = True Then
ElseIf LineOfText.Chars(i) <> " " And blnSpaces = True Then
blnSpaces = False
currNumber += 1
ElseIf LineOfText.Chars(i) <> " " And blnSpaces = False Then
End If
If currNumber = DataNumber And blnSpaces = False Then
sData &= LineOfText.Chars(i)
End If
Next
WriteData(sData)
Return sData
End Function
Any ideas for how to get the values of these line or how to adjust the function to do so, I would appreciate it.