下面的代碼不顯示You Win!
陣列不能正確比較
你能幫我找到問題嗎? 這兩個數組都是字符串。
Sub checkwin()
Dim flag As Boolean = False
For i As Integer = 0 To win.Length - 1
If mess(i) = win(i) Then
flag = True
Else
flag = False
Exit For
End If
Next
If flag = True Then
lbl1.Content = "You Win!!"
Timer.Stop()
Dim name As String = txtName.Text
Dim data As String = "insert into puzzleTable([picName], [name], [moves], [time]) values ('mona','" & name & "','" & counter & "','" & x & "')"
mySql.executeSqlQuery(data)
End If
End Sub
請提供'mess'和'win'數組的內容。 –
你也可以縮短默認的代碼設置標誌爲真,並且只檢查是否不亂(i)= win(i) –
在If和step中加入一個斷點。您可能會遇到字符串填充問題,即其中一個字符串具有尾隨空格。 – Rikalous