Visual studio 2010 VB 2010 Express:下一个错误
所以我刚刚开始学习VB,我想我误解了我一直遵循的教程,因为我不知道我在这里做错了什么。也许我想得太多了 问题在于以下行,“IndexOutOfRangeException” 提前谢谢你的帮助Visual studio 2010 VB 2010 Express:下一个错误,visual-studio-2010,Visual Studio 2010,所以我刚刚开始学习VB,我想我误解了我一直遵循的教程,因为我不知道我在这里做错了什么。也许我想得太多了 问题在于以下行,“IndexOutOfRangeException” 提前谢谢你的帮助 Public Function FindTabPos(ByVal low As Integer, ByVal high As Integer) If opCounter >= 3 Then Dim TextLine As String Dim TrueCou
Public Function FindTabPos(ByVal low As Integer, ByVal high As Integer)
If opCounter >= 3 Then
Dim TextLine As String
Dim TrueCount As Integer
TrueCount = 0
TextLine = ""
Dim aryTextLine() As String
If System.IO.File.Exists(configLoc) = True Then
Dim objReader As New System.IO.StreamReader(configLoc)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
aryTextLine = TextLine.Split(",")
For i = 0 To UBound(aryTextLine)
MsgBox(aryTextLine(i))
Next i
For i = low To high
If aryTextLine(i) = "True" Then
TrueCount = TrueCount + 1
End If
Next i
End If
Return TrueCount
Else
Return False
End If
End Function
低和高的价值是什么?有多少项有aryTextLine?对于i=从低到高,我不太了解VB,但对于i=从低到高-1,不应该是吗?aryTextLine中有48项。我当前使用的值是0或1表示低,2和7之间表示高。
Public Function FindTabPos(ByVal low As Integer, ByVal high As Integer)
If opCounter >= 3 Then
Dim TextLine As String
Dim TrueCount As Integer
TrueCount = 0
TextLine = ""
Dim aryTextLine() As String
If System.IO.File.Exists(configLoc) = True Then
Dim objReader As New System.IO.StreamReader(configLoc)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
aryTextLine = TextLine.Split(",")
For i = 0 To UBound(aryTextLine)
MsgBox(aryTextLine(i))
Next i
For i = low To high
If aryTextLine(i) = "True" Then
TrueCount = TrueCount + 1
End If
Next i
End If
Return TrueCount
Else
Return False
End If
End Function
aryTextLine = TextLine.Split(New String() {Environment.NewLine}, StringSplitOptions.None)