所以我试图读取一个文件并将索引设置为计数器,这样我就可以在文件中从一个字符移动到另一个字符,以找到°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)
答案 0 :(得分: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