最近写代码越来越垃圾了

(前几天写的)

就为了一个事件写了那么多的IF,天啊,再这样发展下去,不堪设想;不过应该没什么发展了吧(其实有些IF可以看起来可以简化,这是自己故意写的)

With VSFlexGrid1
        For currentRow = 1 To .Rows - 1
            Set rsSign = New Recordset
            rsSign.Open "Select * from 培训报名表 where 合同编号='" & .TextMatrix(currentRow, 1) & "'", cnSign, adOpenStatic, adLockOptimistic
            'Do While Not rsSign.EOF
                For i = 1 To 56
                    Ti = "课时" & i
                         '判断是否是空的
                        If IsNull(rsSign.Fields(Ti).Value) Then '空的就可以写
                            '判断是否已经有了这个日期
                            If PreSignDate = SystemDay Then
                                '有该日期警告
                                If MsgBox(rsSign!学员中文名 & " 在 " & SystemDay & txtSign(0).Text & " 的记录已有,是否继续输入?", vbOKCancel, "输入警告") = vbOK Then
                                    '重复了但用户选择继续输入
                                    If .TextMatrix(currentRow, 5) = "-1" Then
                                       rsSign.Fields(Ti).Value = SystemDay & "Y"
                                       rsSign.Update
                                       Exit For         '输入已到结束此次循环
                                    Else
                                       rsSign.Fields(Ti).Value = SystemDay & "N"
                                       rsSign.Update
                                       Exit For         '输入未到结束此次循环
                                    End If
                                Else
                                    Exit For            '重复了但用户选择不输入,结束此次循环
                                End If
                            Else
                                '没有该日期不警告
                                    If .TextMatrix(currentRow, 5) = "-1" Then
                                       rsSign.Fields(Ti).Value = SystemDay & "Y"
                                       rsSign.Update
                                       Exit For         '输入已到结束此次循环
                                    Else
                                       rsSign.Fields(Ti).Value = SystemDay & "N"
                                       rsSign.Update
                                       Exit For         '输入未到结束此次循环
                                    End If
                            End If
                        Else
                        '不为空则记录这个值
                            PreSignDate = Left(rsSign.Fields(Ti).Value, Len(rsSign.Fields(Ti).Value) - 1)
                        End If
                Next i
                rsSign.MoveNext
           ' Loop
            rsSign.Close
             PreSignDate = ""
        Next
    End With

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值