以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  按ESC退出循环  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149852)

--  作者:刘林
--  发布时间:2020/5/13 19:09:00
--  按ESC退出循环
Dim tb1 As Table = Tables("学生信息A_table1")
tb1.Position=0
For Each r As Row In tb1.Rows
    Dim dr As DataRow = DataTables("学生信息").sqlfind("身份证件号=\'" & r("身份证件号") & "\' and [_identify]<>\'" &  r("_identify") & "\'")
    Dim str As String=""
    If dr IsNot Nothing
        str= str & "身份证号与" & dr("学校名称") & dr("班级") & dr("学生姓名") & "重复;"
    End If
    If r("学籍号").length<>19
        str= str & vbcrlf & "学籍号不规范;"
    End If
   If r("户籍地址").length<=5
        str= str & vbcrlf & "户籍地址不规范;"
    End If
    r("重复情况")= str    
    With tb1
        .Position = .Position + 1
    End With
Next


老师在这个循环中我想做个按esc停止循环并退出怎么设计

--  作者:有点蓝
--  发布时间:2020/5/14 8:38:00
--  
建个退出按钮,按钮代码
vars("tc") = true

加上退出判断
Dim tb1 As Table = Tables("学生信息A_table1")
tb1.Position=0
For Each r As Row In tb1.Rows
if  vars("tc") = true then exit for
    Dim dr As DataRow = DataTables("学生信息").sqlfind("身份证件号=\'" & r("身份证件号") & "\' and [_identify]<>\'" &  r("_identify") & "\'")
    Dim str As String=""
    If dr IsNot Nothing
        str= str & "身份证号与" & dr("学校名称") & dr("班级") & dr("学生姓名") & "重复;"
    End If
    If r("学籍号").length<>19
        str= str & vbcrlf & "学籍号不规范;"
    End If
   If r("户籍地址").length<=5
        str= str & vbcrlf & "户籍地址不规范;"
    End If
    r("重复情况")= str    
    With tb1
        .Position = .Position + 1
    End With
application.doevents
Next