基本上,除非它在消息框中,否則我無法修剪它..這很難解釋。 這裏有2張圖片: 1. http://gyazo.com/83b0a996e607f7013d998f6f800650f1 2. http://gyazo.com/e1fe9d8adb4a522479f6621d29e90e9d將字符串拆分爲數組時出錯
Dim value As String = ary(0).Trim()
'Dim value1 As String = ary(1).Trim()
Dim R As String
Dim G As String
Dim B As String
Dim outline As String
Dim outlineColor As String
R = Chr(34) & "MouseColorR" & Chr(34)
G = Chr(34) & "MouseColorG" & Chr(34)
B = Chr(34) & "MouseColorB" & Chr(34)
outline = Chr(34) & "ThickMouseEdges" & Chr(34)
outlineColor = Chr(34) & "ThickMouseEdgesPackedColor" & Chr(34)
'based on the value after the equals sign, do something
If value = R Then
MsgBox(ary(1).Trim(Chr(44)))
ElseIf value = G Then
MsgBox("finally")
ElseIf value = B Then
MsgBox("finally")
ElseIf value = outline Then
MsgBox("finally")
這個作品^^^^
這並不:
Dim value As String = ary(0).Trim()
this is the error---> Dim value1 As String = ary(1).Trim()
Dim R As String
Dim G As String
Dim B As String
Dim outline As String
Dim outlineColor As String
R = Chr(34) & "MouseColorR" & Chr(34)
G = Chr(34) & "MouseColorG" & Chr(34)
B = Chr(34) & "MouseColorB" & Chr(34)
outline = Chr(34) & "ThickMouseEdges" & Chr(34)
outlineColor = Chr(34) & "ThickMouseEdgesPackedColor" & Chr(34)
'based on the value after the equals sign, do something
If value = R Then
MsgBox(ary(1).Trim(Chr(44)))
ElseIf value = G Then
MsgBox("finally")
ElseIf value = B Then
MsgBox("finally")
ElseIf value = outline Then
MsgBox("finally")
ElseIf value = outlineColor Then
MsgBox("finally")
和錯誤是:類型的未處理的異常在Terraria Smart Cursor.exe中出現'System.IndexOutOfRangeException'
附加信息:索引超出了數組的範圍。
整個代碼:
公共類Form1中
Private Sub NsCheckBox1_CheckedChanged(sender As Object) Handles NsCheckBox1.CheckedChanged
NsGroupBox2.Enabled = NsCheckBox1.Checked
End Sub
Private Sub NsTrackBar1_Scroll(sender As Object) Handles NsTrackBar1.Scroll
NsLabel4.Value1 = NsTrackBar1.Value
End Sub
Private Sub NsTrackBar2_Scroll(sender As Object) Handles NsTrackBar2.Scroll
NsLabel5.Value1 = NsTrackBar2.Value
End Sub
Private Sub NsTrackBar3_Scroll(sender As Object) Handles NsTrackBar3.Scroll
NsLabel6.Value1 = NsTrackBar3.Value
End Sub
Private Sub NsTrackBar6_Scroll(sender As Object) Handles NsTrackBar6.Scroll
NsLabel9.Value1 = NsTrackBar6.Value
End Sub
Private Sub NsTrackBar5_Scroll(sender As Object) Handles NsTrackBar5.Scroll
NsLabel8.Value1 = NsTrackBar5.Value
End Sub
Private Sub NsTrackBar4_Scroll(sender As Object) Handles NsTrackBar4.Scroll
NsLabel7.Value1 = NsTrackBar4.Value
End Sub
Private Sub NsButton1_Click_1(sender As Object, e As EventArgs) Handles NsButton1.Click
If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
NsLabel4.Value1 = ColorDialog1.Color.R
NsLabel5.Value1 = ColorDialog1.Color.G
NsLabel6.Value1 = ColorDialog1.Color.B
NsTrackBar1.Value = NsLabel4.Value1
NsTrackBar2.Value = NsLabel5.Value1
NsTrackBar3.Value = NsLabel6.Value1
End If
End Sub
Private Sub NsButton2_Click_1(sender As Object, e As EventArgs) Handles NsButton2.Click
If ColorDialog2.ShowDialog() = Windows.Forms.DialogResult.OK Then
NsLabel9.Value1 = ColorDialog2.Color.R
NsLabel8.Value1 = ColorDialog2.Color.G
NsLabel7.Value1 = ColorDialog2.Color.B
NsTrackBar6.Value = NsLabel9.Value1
NsTrackBar5.Value = NsLabel8.Value1
NsTrackBar4.Value = NsLabel7.Value1
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'reads each line from the text file one at a time
For Each line As String In IO.File.ReadLines("C:\Users\Matthew\Documents\My Games\Terraria\config.json")
'split the string by equals sign
Dim ary As String() = line.Split(":")
Dim value As String = ary(0).Trim()
Dim value1 As String = ary(1).Trim()
Dim R As String
Dim G As String
Dim B As String
Dim outline As String
Dim outlineColor As String
R = Chr(34) & "MouseColorR" & Chr(34)
G = Chr(34) & "MouseColorG" & Chr(34)
B = Chr(34) & "MouseColorB" & Chr(34)
outline = Chr(34) & "ThickMouseEdges" & Chr(34)
outlineColor = Chr(34) & "ThickMouseEdgesPackedColor" & Chr(34)
'based on the value after the equals sign, do something
If value = R Then
MsgBox(ary(1).Trim(Chr(44)))
ElseIf value = G Then
MsgBox("finally")
ElseIf value = B Then
MsgBox("finally")
ElseIf value = outline Then
MsgBox("finally")
ElseIf value = outlineColor Then
MsgBox("finally")
End If
Next
End Sub
末級
請發佈一個簡短但完整的例子* code *。沒有理由在這裏使用圖像。 –
這很容易解釋:你把代碼粘貼到你的問題中,並說你得到一個ArgumentOutOfRangeException並且說出它正在發生的是哪一行。 –
這仍然不是一個簡短但完整的例子。它既不短也不完整,也不告訴我們你分裂的價值。也不清楚爲什麼當沒有C#的時候你用C#標記了這個標籤。請閱讀http://tinyurl.com/stack-hints –