0

So I am trying to read through a file and I have index set as a counter so I can move from character to character in the file to find the index where the °s are at. I keep getting IndexOutOfRangeException even though I have no clue what is wrong.

 Dim chr As String
    Dim c1 As String
    Dim c2 As String
    Dim c3 As String
    Static index As Integer = -1
    index += 1
    chr = numDat(index)

    While Asc(chr) <> 176
        index += 1
        chr = numDat(index)
    End While

I am getting the error at the index in chr = numDat(index). Any help will be appreciated, thanks!

Edit: I forgot to mention that numDat is a string that has read in the whole file already.

numDat = My.Computer.FileSystem.ReadAllText(path + fileName)

1 Answers1

0

You can find all occurrences of ° like this:

numDat = My.Computer.FileSystem.ReadAllText(path + fileName)
Dim index As Integer = numDat.IndexOf("°")
While index <> -1
    Debug.Print(index)
    index = numDat.IndexOf("°", index + 1)
End While
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40