以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]上一个单元格输入内容总被下一个单元格内容处理时继承  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=88488)

--  作者:33chyh
--  发布时间:2016/8/3 16:50:00
--  [求助]上一个单元格输入内容总被下一个单元格内容处理时继承

想法说明:我在“卷1答”的表事件datacolchanged中输入以下代码,完成通过比较“卷1答”表中“客观题1”答案和“客观题答案”表中“客观题1”答案对比,找出两者不同的答案,并借助“客观问题描述”表中相关选项值在“学生问题频度”表中记录相关数值。例如“客观题答案”中“客观题1”的答案是“a”,“卷1问”的答案是“b”,需要通过程序借助“客观问题描述”表中找出a、b两个选项的对应描述的值是“知1”和“知2”并给二者分别赋值“1”,再通过两个值在“学生问题频度”表中找到相关列“知1”列和“知2”列,最后将两个值“1”填到“学生问题频度”表的对应单元格中。

疑问:在填写“卷1答”表“客观题2”答案录入后,在“学生问题频度”表中会将“客观题1”录入答案对应值再一次统计。

请专家帮助我看看代码是在哪里出现问题?

Dim kmdr As DataRow = DataTables("客观问题描述").find("试卷号= \'" & DataTables("卷1答").Name.chars(1) & "\'")
Dim kfdr As DataRow = DataTables("客观题答案").find("试卷号 = \'" & DataTables("卷1答").Name.chars(1) & "\'" )
Dim kgtfwdr As DataRow = DataTables("学生问题频度").find("学号 = \'" & e.DataRow("学号") & "\'")
Dim kegtdr1 As String = e.DataRow("客观题1")
Dim kegtdadr1 As String = kfdr("客观题1")
If e.DataRow("客观题1") IsNot Nothing Then
    If kegtdr1.contains("a") = True And kegtdadr1.contains("a") = True
    Else If kegtdr1.contains("a") = True Or kegtdadr1.contains("a") = True Then
                Select Case kmdr("第1题A范")
            Case "知1"
                kgtfwdr("知1") = 1
            Case "知2"
                kgtfwdr("知2") = 1
            Case "知3"
                kgtfwdr("知3") = 1
            Case "知4"
                kgtfwdr("知4") = 1
        End Select
    End If
    If kegtdr1.contains("b") = True And kegtdadr1.contains("b") = True
    Else If kegtdr1.contains("b") = True Or kegtdadr1.contains("b") = True Then
                Select Case kmdr("第1题B范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
    If kegtdr1.contains("c") = True And kegtdadr1.contains("c") = True
    Else If kegtdr1.contains("c") = True Or kegtdadr1.contains("c") = True Then
                Select Case kmdr("第1题C范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
    If kegtdr1.contains("d") = True And kegtdadr1.contains("d") = True
    Else If kegtdr1.contains("d") = True Or kegtdadr1.contains("d") = True Then
                Select Case kmdr("第1题D范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
End If
Dim kegtdr2 As String = e.DataRow("客观题2")
Dim kegtdadr2 As String = kfdr("客观题2")
If e.DataRow.Isnull("客观题2")  Then
Else If kfdr("客观题2")  IsNot Nothing Then
    If kegtdr2.contains("a") = True And kegtdadr2.contains("a") = True
    Else If kegtdr2.contains("a") = True OrElse kegtdadr2.contains("a") = True Then
               Select Case kmdr("第2题A范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("b") = True And kegtdadr2.contains("b") = True
    Else If kegtdr2.contains("b") = True OrElse kegtdadr2.contains("b") = True Then
                Select Case kmdr("第2题B范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("c") = True And kegtdadr2.contains("c") = True
    Else If kegtdr2.contains("c") = True OrElse kegtdadr2.contains("c") = True Then
               Select Case kmdr("第2题C范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("d") = True And kegtdadr2.contains("d") = True
    Else If kegtdr2.contains("d") = True OrElse kegtdadr2.contains("d") = True Then
                Select Case kmdr("第2题D范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
End If
If e.DataRow.IsNull("客观题1") And e.DataRow.IsNull("客观题2") Then
    kgtfwdr("知1") = Nothing
    kgtfwdr("知2") = Nothing
    kgtfwdr("知3") = Nothing
    kgtfwdr("知4") = Nothing
End If

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:疑问.foxdb


--  作者:大红袍
--  发布时间:2016/8/3 17:05:00
--  

 在前面加上代码

 


    kgtfwdr("知1") = Nothing
    kgtfwdr("知2") = Nothing
    kgtfwdr("知3") = Nothing
    kgtfwdr("知4") = Nothing


--  作者:33chyh
--  发布时间:2016/8/3 17:28:00
--  
我在第二题的代码前面加上您写的代码后,第一题处理的数据没有出现在“学生问题频度”表中。如果按照输入的数据处理结果知1、知2、知3的值应该是2、2、1,现在的结果是1、1、1。请您帮我再看看。
--  作者:大红袍
--  发布时间:2016/8/3 17:48:00
--  

我测试没问题

 

Dim kmdr As DataRow = DataTables("客观问题描述").find("试卷号= \'" & DataTables("卷1答").Name.chars(1) & "\'")
Dim kfdr As DataRow = DataTables("客观题答案").find("试卷号 = \'" & DataTables("卷1答").Name.chars(1) & "\'" )
Dim kgtfwdr As DataRow = DataTables("学生问题频度").find("学号 = \'" & e.DataRow("学号") & "\'")
Dim kegtdr1 As String = e.DataRow("客观题1")
Dim kegtdadr1 As String = kfdr("客观题1")

kgtfwdr("知1") = Nothing
kgtfwdr("知2") = Nothing
kgtfwdr("知3") = Nothing
kgtfwdr("知4") = Nothing
If e.DataRow("客观题1") IsNot Nothing Then
    If kegtdr1.contains("a") = True And kegtdadr1.contains("a") = True
    Else If kegtdr1.contains("a") = True Or kegtdadr1.contains("a") = True Then
        Select Case kmdr("第1题A范")
            Case "知1"
                kgtfwdr("知1") = 1
            Case "知2"
                kgtfwdr("知2") = 1
            Case "知3"
                kgtfwdr("知3") = 1
            Case "知4"
                kgtfwdr("知4") = 1
        End Select
    End If
    If kegtdr1.contains("b") = True And kegtdadr1.contains("b") = True
    Else If kegtdr1.contains("b") = True Or kegtdadr1.contains("b") = True Then
        Select Case kmdr("第1题B范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
    If kegtdr1.contains("c") = True And kegtdadr1.contains("c") = True
    Else If kegtdr1.contains("c") = True Or kegtdadr1.contains("c") = True Then
        Select Case kmdr("第1题C范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
    If kegtdr1.contains("d") = True And kegtdadr1.contains("d") = True
    Else If kegtdr1.contains("d") = True Or kegtdadr1.contains("d") = True Then
        Select Case kmdr("第1题D范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") +  1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") +  1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") +  1
        End Select
    End If
End If
Dim kegtdr2 As String = e.DataRow("客观题2")
Dim kegtdadr2 As String = kfdr("客观题2")
If e.DataRow.Isnull("客观题2")  Then
Else If kfdr("客观题2")  IsNot Nothing Then
    If kegtdr2.contains("a") = True And kegtdadr2.contains("a") = True
    Else If kegtdr2.contains("a") = True OrElse kegtdadr2.contains("a") = True Then
        Select Case kmdr("第2题A范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("b") = True And kegtdadr2.contains("b") = True
    Else If kegtdr2.contains("b") = True OrElse kegtdadr2.contains("b") = True Then
        Select Case kmdr("第2题B范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("c") = True And kegtdadr2.contains("c") = True
    Else If kegtdr2.contains("c") = True OrElse kegtdadr2.contains("c") = True Then
        Select Case kmdr("第2题C范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
    If kegtdr2.contains("d") = True And kegtdadr2.contains("d") = True
    Else If kegtdr2.contains("d") = True OrElse kegtdadr2.contains("d") = True Then
        Select Case kmdr("第2题D范")
            Case "知1"
                kgtfwdr("知1") = kgtfwdr("知1") + 1
            Case "知2"
                kgtfwdr("知2") = kgtfwdr("知2") + 1
            Case "知3"
                kgtfwdr("知3") = kgtfwdr("知3") + 1
            Case "知4"
                kgtfwdr("知4") = kgtfwdr("知4") + 1
        End Select
    End If
End If
If e.DataRow.IsNull("客观题1") And e.DataRow.IsNull("客观题2") Then
    kgtfwdr("知1") = Nothing
    kgtfwdr("知2") = Nothing
    kgtfwdr("知3") = Nothing
    kgtfwdr("知4") = Nothing
End If


--  作者:33chyh
--  发布时间:2016/8/3 18:08:00
--  
谢谢大红袍老师。我已经将您帮我修改的代码进行测试完毕,已经帮助我解决问题了。