VB6总结VI

一.表A为主表,另有表B、C、D,但是B、C、D表中的人是A的子集。现按A遍历每一个人,然后分别拿A中人的UIN去B、C、D中遍历找相同的UIN(For...Next),如果找到了,会进行一些相应的加减法运算(例如B中的日期减去A中的日期,C中的日期减去B中的日期),如果找不到,则在grid中显示空。代码中还有给符合一定条件的格子加颜色。

    intFollowUpListRow = 1
    fgFollowUpList.Rows = 1
    Do While Not rstSQL.EOF
        fgFollowUpList.Rows = fgFollowUpList.Rows + 1
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListHiddenFieldCol) = IIf(IsNull(rstSQL("id")), "", rstSQL("id"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListSNoCol) = intFollowUpListRow
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListUINCol) = IIf(IsNull(rstSQL("patient_uin")), "", rstSQL("patient_uin"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListNameCol) = IIf(IsNull(rstSQL("patient_name")), "", rstSQL("patient_name"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListRegDateCol) = IIf(IsNull(rstSQL("date_registration")), "", Format(rstSQL("date_registration"), "dd/mm/yyyy"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListCurrentDefaultCol) = IIf(IsNull(rstSQL("current_default")), "", rstSQL("current_default"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDefaultDateCol) = IIf(IsNull(rstSQL("DateDefault")), "", Format(rstSQL("DateDefault"), "dd/mm/yyyy"))
        fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysMissCol) = IIf(IsNull(DateDiff("d", rstSQL("DateDefault"), Date)), "", DateDiff("d", rstSQL("DateDefault"), Date))
        
        sql = 0
        For r = 1 To fgNPHU.Rows - 1
            If fgNPHU.TextMatrix(r, 2) = rstSQL("patient_uin") Then sql = r
        Next r
        If sql = 0 Then
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysReferNPHUCol) = ""
        Else
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysReferNPHUCol) = DateDiff("d", rstSQL("DateDefault"), fgNPHU.TextMatrix(intFollowUpListRow, 11))
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListReferNPHUDateCol) = fgNPHU.TextMatrix(intFollowUpListRow, 11)
        End If
        
        sql = 0
        For r = 1 To fgFirst.Rows - 1
            If fgFirst.TextMatrix(r, 2) = rstSQL("patient_uin") Then sql = r
        Next r
        If sql <> 0 Then
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysFirstReplyCol) = DateDiff("d", fgNPHU.TextMatrix(intFollowUpListRow, 11), fgFirst.TextMatrix(intFollowUpListRow, 12))
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListFirstReplyDateCol) = fgFirst.TextMatrix(intFollowUpListRow, 12)
        Else
            strCal = DateDiff("d", fgNPHU.TextMatrix(intFollowUpListRow, 11), Date)
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysFirstReplyCol) = "no reply yet (" & strCal & ")"
            If strCal > 14 Then
                With fgFollowUpList
                    .Row = intFollowUpListRow
                    .Col = fFollowUpListDaysFirstReplyCol
    '                    .CellBackColor = &HEAD5FF
                    .CellBackColor = &HFF80FF   '粉红色
                End With
            End If
        End If
        
        sql = 0
        For r = 1 To fgLast.Rows - 1
            If fgLast.TextMatrix(r, 2) = rstSQL("patient_uin") Then sql = r
        Next r
        If sql <> 0 Then
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysLastReplyCol) = DateDiff("d", fgLast.TextMatrix(intFollowUpListRow, 13), Date)
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListLastReplyDateCol) = fgLast.TextMatrix(intFollowUpListRow, 13)
            If fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysLastReplyCol) > 14 Then
                With fgFollowUpList
                    .Row = intFollowUpListRow
                    .Col = fFollowUpListDaysLastReplyCol
    '                    .CellBackColor = &HEAD5FF
                    .CellBackColor = &HFF80FF   '粉红色
                End With
            End If
        Else
            fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysLastReplyCol) = " "
        End If
             
        If fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysMissCol) > 14 And fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysMissCol) <= 40 Then
            With fgFollowUpList
                .Row = intFollowUpListRow
                .Col = fFollowUpListDaysMissCol
                .CellBackColor = &HFF80FF   '粉红色
            End With
        ElseIf fgFollowUpList.TextMatrix(intFollowUpListRow, fFollowUpListDaysMissCol) > 40 Then
            With fgFollowUpList
                .Row = intFollowUpListRow
                .Col = fFollowUpListDaysMissCol
                .CellBackColor = &HFF&   '红色
            End With
        End If
        rstSQL.MoveNext
        intFollowUpListRow = intFollowUpListRow + 1
    Loop


二.VB6中的几个判断语句

1.rstSQL为空

If (rstSQL.EOF And rstSQL.BOF) Then
2.rstSQL不为空
If Not (rstTBCUDefaulter.EOF And rstTBCUDefaulter.BOF) Then
3.rstSQL中的name列不为空
If Not IsNull(rstTBCUDefaulter("date_birth")) Then


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值