Public Sub CheckTwo(ByVal str As String)
If ((arrayTwo(colArray(0), colArray(0)) = str) And (arrayTwo(colArray(1), colArray(1)) = str)) Or
((arrayTwo(colArray(0), colArray(1)) = str) And (arrayTwo(colArray(1), colArray(0)) = str)) Then
MsgBox(str + " Won")
End If
For i = 0 To colArray.Length - 1
If (arrayTwo(colArray(i), colArray(0)) = str) And (arrayTwo(colArray(i), colArray(1)) = str) Or
(arrayTwo(colArray(0), colArray(i)) = str) And (arrayTwo(colArray(1), colArray(i)) = str) Then
MsgBox(str + " Won")
End If
Next
End Sub
Public Sub CheckThree(ByVal str As String)
If ((arrayTwo(colArray(0), colArray(0)) = str) And (arrayTwo(colArray(1), colArray(1)) = str) And
(arrayTwo(colArray(2), colArray(2)) = str)) Or
((arrayTwo(colArray(0), colArray(2)) = str) And (arrayTwo(colArray(1), colArray(1)) = str) And
(arrayTwo(colArray(2), colArray(0)) = str)) Then
MsgBox(str + " Won")
End If
For i = 0 To colArray.Length - 1
If ((arrayTwo(colArray(0), colArray(i)) = str) And (arrayTwo(colArray(1), colArray(i)) = str) And
(arrayTwo(colArray(2), colArray(i)) = str)) Or
((arrayTwo(colArray(i), colArray(0)) = str) And (arrayTwo(colArray(i), colArray(1)) = str) And
(arrayTwo(colArray(i), colArray(2)) = str)) Then
MsgBox(str + " Won")
End If
Next
End Sub
Public Sub CheckFour(ByVal str As String)
If ((arrayTwo(colArray(0), colArray(0)) = str) And (arrayTwo(colArray(1), colArray(1)) = str) And
(arrayTwo(colArray(2), colArray(2)) = str) And (arrayTwo(colArray(3), colArray(3)) = str)) Or
((arrayTwo(colArray(3), colArray(0)) = str) And (arrayTwo(colArray(2), colArray(1)) = str) And
(arrayTwo(colArray(1), colArray(2)) = str) And (arrayTwo(colArray(0), colArray(3)) = str)) Then
MsgBox(str + " Won")
End If
For i = 0 To colArray.Length - 1
If ((arrayTwo(colArray(0), colArray(i)) = str) And (arrayTwo(colArray(1), colArray(i)) = str) And
(arrayTwo(colArray(2), colArray(i)) = str) And (arrayTwo(colArray(3), colArray(i)) = str)) Or
((arrayTwo(colArray(i), colArray(0)) = str) And (arrayTwo(colArray(i), colArray(1)) = str) And
(arrayTwo(colArray(i), colArray(2)) = str) And (arrayTwo(colArray(i), colArray(3)) = str)) Then
MsgBox(str + " Won")
End If
Next
End Sub
依此类推,动态输入colArray(x,x)
答案 0 :(得分:0)
如果我们知道你想要完成的事情,那可能会有所帮助。
无论如何,你可以考虑以下几点:
Public Sub CheckN(ByVal str As String, ByVal CheckCount As Integer)
For i = 0 To CheckCount - 1
Dim TruthList As New List(Of Boolean)
For j = 0 To colArray.Length - 1
If arrayTwo(colArray(i), colArray(j)) = str Then
TruthList.Add(True)
End If
Next
If TruthList.Distinct.Count < 2 Then
MsgBox(str + " Won")
End If
Next
End Sub