以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]窗口筛选问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=127001)

--  作者:cqlwsam
--  发布时间:2018/11/2 15:20:00
--  [求助]窗口筛选问题
如图:

图片点击可在新窗口打开查看此主题相关图片如下:360截图1825082911214695.png
图片点击可在新窗口打开查看

当我在窗口的文本框中录入进行筛选。如果输入的编号没在表中的范围,应该筛选结果是没有。现在我不知道如何跳出循环语句?

代码:
Dim txt As String = e.Form.controls("TextBox6").text
Dim tbl As Table = Tables("疾病编码库维护_Table1")
Dim txt1 As String
If txt.length =3 Then
    For Each dr As DataRow In DataTables("疾病编码库").DataRows
        txt1 = dr("ICD10编码")
        Dim txt2() As String = txt1.Split("-")
        If txt>= txt2(0) And txt <= txt2(1) Then
            tbl.Filter = "[ICD10编码] =\'" & txt1 & "\'"
            Exit For
        End If
    Next
\'   tbl.Filter = "[ICD10编码] like\'" & txt & "\'"
Else
    tbl.Filter = ""
End If


--  作者:cqlwsam
--  发布时间:2018/11/2 15:27:00
--  
如图,如果我输入A08,能筛出“肠道传染病”,如果我输入A12,表中应该没有内容才对。

就在next后面的语句,如果有结果,就不执行next后面的语句;没有结果才执行。
[此贴子已经被作者于2018/11/2 15:37:18编辑过]

--  作者:有点甜
--  发布时间:2018/11/2 16:29:00
--  
Dim txt As String = e.Form.controls("TextBox6").text
Dim tbl As Table = Tables("疾病编码库维护_Table1")
Dim txt1 As String
If txt.length =3 Then
    Dim found As Boolean = False
    For Each dr As DataRow In DataTables("疾病编码库").DataRows
        txt1 = dr("ICD10编码")
        Dim txt2() As String = txt1.Split("-")
        If txt>= txt2(0) And txt <= txt2(1) Then
            \'            tbl.Filter = "[ICD10编码] =\'" & txt1 & "\'"
            found = True
            Exit For
        End If
    Next
    If found Then
        tbl.Filter = "[ICD10编码] like\'" & txt & "\'"
    Else
        msgbox("没找到")
    End If
Else
    tbl.Filter = ""
End If

--  作者:cqlwsam
--  发布时间:2018/11/2 16:57:00
--  
谢谢!