0

所以我试图通读一个文件,并将索引设置为一个计数器,这样我就可以在文件中从一个字符移动到另一个字符以找到°s所在的索引。即使我不知道出了什么问题,我也会不断收到 IndexOutOfRangeException。

 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

我在 chr = numDat(index) 中的索引处收到错误。任何帮助将不胜感激,谢谢!

编辑:我忘了提到 numDat 是一个已经读入整个文件的字符串。

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

1 回答 1

0

您可以找到所有°类似的情况:

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
于 2015-09-26T03:05:54.213 回答