以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多项选择题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=175386) |
-- 作者:lisangyu -- 发布时间:2022/3/2 18:56:00 -- 多项选择题 蓝总: If Tables("试题").current("题型") = “多选题” Then e.Form.Controls("GroupBox3").Enabled = False e.Form.Controls("GroupBox2").Enabled = True Dim Str As String If e.Form.Controls("显示答案").Checked = False If e.Form.Controls("CheckBox1").Checked = True Then str = str & "A" End If If e.Form.Controls("CheckBox2").Checked = True Then str = str & "B" End If If e.Form.Controls("CheckBox3").Checked = True Then str = str & "C" End If If e.Form.Controls("CheckBox4").Checked = True Then str = str & "D" End If \' MessageBox.Show(str) If str IsNot Nothing Then If str = dr("正确答案") Then e.Form.Controls("提示").text = "恭喜你答对了!" Functions.Execute("Yes") Else If dr("正确答案").Contains(str) Then e.Form.Controls("提示").text = "" Else e.Form.Controls("提示").text = "对不起,你答错了!" Functions.Execute("No") End If End If End If End If 蓝总:为了实现多项选择的效果,我选择CheckBox实现,测试后,如果按ABCD正常的顺序勾选没有问题,但是测试出了一个问题,假如多项选择题,答案是ABCD,考虑实际情况,当用户选择ABC时,系统不提示错误,因为是包含的关系,但是选择ABD时,提示就错误了,难道不是包含关系吗?
|
-- 作者:有点蓝 -- 发布时间:2022/3/3 8:44:00 -- 不是包含关系。 这种需要拆开判断 If str = dr("正确答案") Then e.Form.Controls("提示").text = "恭喜你答对了!" Functions.Execute("Yes") Else e.Form.Controls("提示").text = "" for each c as char in str If dr("正确答案").Contains(c) = false Then e.Form.Controls("提示").text = "对不起,你答错了!" Functions.Execute("No") exit for next End If |
-- 作者:lisangyu -- 发布时间:2022/3/3 10:15:00 -- If Tables("试题").current("题型") = “多选题” Then e.Form.Controls("GroupBox3").Enabled = False e.Form.Controls("GroupBox2").Enabled = True Dim Str As String If e.Form.Controls("显示答案").Checked = False If e.Form.Controls("CheckBox1").Checked = True Then str = str & "A" End If If e.Form.Controls("CheckBox2").Checked = True Then str = str & "B" End If If e.Form.Controls("CheckBox3").Checked = True Then str = str & "C" End If If e.Form.Controls("CheckBox4").Checked = True Then str = str & "D" End If If str IsNot Nothing Then If str = dr("正确答案") Then e.Form.Controls("提示").text = "恭喜你答对了!" Functions.Execute("Yes") Else e.Form.Controls("提示").text = "" For Each c As Char In str If dr("正确答案").Contains(c) = False Then e.Form.Controls("提示").text = "对不起,你答错了!" Functions.Execute("No") End If Exit For Next End If End If End If End If 蓝总:测试后,还有缺陷。假如答案是ABD,如果按顺序选择ABD,提示"恭喜你答对了!",但是选ABC,不提示报错,选ABD后再加选C,也不提示"对不起,你答错了!",只有单选C时,才提示"对不起,你答错了!" |
-- 作者:有点蓝 -- 发布时间:2022/3/3 10:26:00 -- Else e.Form.Controls("提示").text = "" For Each c As Char In str If dr("正确答案").Contains(c) = False Then e.Form.Controls("提示").text = "对不起,你答错了!" Functions.Execute("No") Exit For End If Next End If
|