Henry Ottiz
asked on
passing a value with stream reader AFTER a ";"
i have a textfile (table) that has the following values
1;1,2,
2;1,1,
3;2,2,
up to 250;...
what i need is to create a function that, reads the table, and if the user selected 3(or any other number), it searches within the table (txt file) and passes the value for the selected number AFTER the ";", (meaning for the example:3 value to pass: 2,2,).
i will use that function value to build another string...
i quite can't get it...
suggestions please
1;1,2,
2;1,1,
3;2,2,
up to 250;...
what i need is to create a function that, reads the table, and if the user selected 3(or any other number), it searches within the table (txt file) and passes the value for the selected number AFTER the ";", (meaning for the example:3 value to pass: 2,2,).
i will use that function value to build another string...
i quite can't get it...
suggestions please
If True Then
Dim line As String
Dim sr As New StreamReader(tableselected)
Dim table As String = ""
For x As Integer = 0 To 1000
line = sr.ReadLine()
If line Is Nothing Then 'if the file is over, exit the for loop
table = table.TrimEnd(","c)
Exit For
End If
Dim searchWithinThis As String = line
Dim searchForThis As String = "0;" '= index & ";"
'If index > 10 Then
' searchForThis = index & "0;"
'End If
'If index < 10 Then
' searchForThis = index & "00;"
'End If
Dim tableresult As Boolean = searchWithinThis.Contains(searchForThis)
If tableresult = True Then
Dim range As String = line.Substring(0)
' If index < 10 Then
table = table & line.Substring(2) 'line.StartsWith(";") 'line.Substring(0, 41) '& Chr(3)
'End If
' If range > 10 Then
' table = table & line.StartsWith(";") 'line.Substring(1, 41) '& Chr(3)
'End If
End If
Next x
sr.Close()
return table
ASKER
hi ended up doing differently, used the SPLIT
below code:
below code:
If tbline <> "" Then
flds = tbline.Split(";")
End If
'set each line in the array
sortplanline(i) = spline
tableline(x) = tbline
'PENDING define output of array
If flds.Length > 0 Then
ZIPCODE = get_zipSP(i, TBSPlan.Text)
If ZIPCODE = "" = True Then Continue Do
sptopass = flds(1) & ZIPCODE
If sptopass.Length > 40 = True Then
sptopass = Chr(2) & Strings.Left(sptopass, 39) & ".." '
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window