ACCESS VBA窗体问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 17:31:21
控件就不画了
为什么总是说“您答错了”?无论我输入正确或者错误
Private Sub Command16_Click()
If Combo4 = "+" Then
If [Form_ct]![Text0] + [Form_ct]![Text3] = [Form_ct]![Text17] Then
MsgBox "您答对了"
Beep
ElseIf [Form_ct]![Text0] + [Form_ct]![Text3] <> [Form_ct]![Text17] Then
Beep
MsgBox "您答错了"
End If
End If

End Sub

你写的[Form_ct]![Text0] + [Form_ct]![Text3] 是字符相加,如果要达到数值相加的效果要先进行类型转换如
Private Sub Command16_Click()
If Combo4 = "+" Then
If val([Form_ct]![Text0]) + val([Form_ct]![Text3]) = val([Form_ct]![Text17]) Then
MsgBox "您答对了"
Beep
ElseIf val([Form_ct]![Text0]) + val([Form_ct]![Text3]) <> val([Form_ct]![Text17]) Then
Beep
MsgBox "您答错了"
End If
End If