Foxtable(狐表)用户栏目专家坐堂 → 多项选择题


  共有3417人关注过本帖树形打印复制链接

主题:多项选择题

帅哥哟,离线,有人找我吗?
lisangyu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:461 积分:4277 威望:0 精华:0 注册:2019/8/5 17:49:00
多项选择题  发帖心情 Post By: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时,提示就错误了,难道不是包含关系吗?

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107304 积分:545781 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:461 积分:4277 威望:0 精华:0 注册:2019/8/5 17:49:00
  发帖心情 Post By: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时,才提示"对不起,你答错了!"


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107304 积分:545781 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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

 回到顶部