我試圖使用此腳本將來自文本框的用戶輸入與22個正確的單詞進行比較。我不是在尋找多個案例,例如VICE
在ADVICE
,所以它會是2個值; 我希望它的字符串值只接受相等的值。將字符串與數組中的字符串進行比較
目前,它只識別第一個單詞TIED
並顯示一個消息框「found」,但它不會識別列表中的任何其他單詞。
我在Visual Basic腳本
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim StrCorrect() As String = {"TIED", "VICE", "ICED", "DIVE", "DIET", "DATE", "CITE", "CAVE", "AIDE", "ACED", "CITED", "ACTED", "VACATE", "CATTIE", "ADVICE", "AVIATE", "ACTIVE", "VACATED", "DICTATE", "AVIATED", "ACTIVATE", "ACTIVATED"}
Dim Find As String = userinput
For Each Str As String In StrCorrect
If StrComp(Str, userinput, CompareMethod.Text).ToString = 0 Then
MsgBox("Found" & userinput)
Return
Else : MsgBox("incorrect word")
Return
End If
Next
End Sub
您可能要更何況你是語言寫這個。'visual-studio'不是一種語言。 – Yakk 2013-04-25 15:29:33
我的VB有點生疏,但是你不想用圓括號代替大括號嗎? – Melanie 2013-04-25 15:38:21
'我希望它的字符串值只接受相等的值.'相等的值並不意味着'VICE' ='Vice' – 2013-04-25 16:05:09