N
.Net Sports
I'm trying to parse some text from an open file , and then save it and
display it, but with the code below, using two instances of IndexOf
doesnt work (error: length cannot be less than zero.), and using
LastIndexOf will grab the very last instance of my "secondkeyword",
which I don't want because there are more than one "secondkeyword"s
remaining in the file:
'''''''''''''''''''''''''''''
Dim mystring2 as string = String.Empty
Dim path2 as String = "c:\inetpub\wwwroot\myfile.txt"
If File.Exists(path2) Then
Dim sr2 As StreamReader = New StreamReader(path2)
mystring2 =sr2.ReadToEnd()
sr2.Close()
End If
Dim zz1 as String
zz1 = mystring2
Dim abc1 as String
Dim Ptr1 As Integer = zz1.IndexOf("firstkeyword")
Dim Ptr2 As Integer = zz1.IndexOf("secondkeyword")
abc1=zz1.Substring(Ptr1, Ptr2-Ptr1+1)
Response.Write(abc1)
'''''''''''''''''''''''''''''''''
??
chumley
display it, but with the code below, using two instances of IndexOf
doesnt work (error: length cannot be less than zero.), and using
LastIndexOf will grab the very last instance of my "secondkeyword",
which I don't want because there are more than one "secondkeyword"s
remaining in the file:
'''''''''''''''''''''''''''''
Dim mystring2 as string = String.Empty
Dim path2 as String = "c:\inetpub\wwwroot\myfile.txt"
If File.Exists(path2) Then
Dim sr2 As StreamReader = New StreamReader(path2)
mystring2 =sr2.ReadToEnd()
sr2.Close()
End If
Dim zz1 as String
zz1 = mystring2
Dim abc1 as String
Dim Ptr1 As Integer = zz1.IndexOf("firstkeyword")
Dim Ptr2 As Integer = zz1.IndexOf("secondkeyword")
abc1=zz1.Substring(Ptr1, Ptr2-Ptr1+1)
Response.Write(abc1)
'''''''''''''''''''''''''''''''''
??
chumley