以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  专家看看,为什么并列条件总是写不对?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=75381)

--  作者:digger_deng
--  发布时间:2015/10/7 14:22:00
--  专家看看,为什么并列条件总是写不对?
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim chk As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim tbl As Table = Tables("学生档案")
If chk.checked Then 


If txt = "" Then
    tbl.Filter = ""
Else
    txt = "\'%" & txt & "%\'"
    tbl.Filter ="\'姓名 Like\' & txt And 在校= True"

End If
Else
If txt = "" Then
    tbl.Filter = ""
Else
    txt = "\'%" & txt & "%\'"
    tbl.Filter ="\'姓名 Like \' & txt And 在校= False"

End If

--  作者:大红袍
--  发布时间:2015/10/7 14:32:00
--  
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim chk As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim tbl As Table = Tables("学生档案")
If chk.checked Then
   
    If txt = "" Then
        tbl.Filter = ""
    Else
        txt = "\'%" & txt & "%\'"
        tbl.Filter ="\'姓名 Like " & txt & " And 在校= True"
    End If
Else
    If txt = "" Then
        tbl.Filter = ""
    Else
        txt = "\'%" & txt & "%\'"
        tbl.Filter ="\'姓名 Like " & txt & " And 在校= False"
    End If
End If

--  作者:qwz405
--  发布时间:2015/10/7 14:36:00
--  

感觉这个地方有问题,别的不懂:

if chk.checked = true then


--  作者:大红袍
--  发布时间:2015/10/7 14:47:00
--  

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim chk As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim tbl As Table = Tables("学生档案")

Dim filter As String
If chk.checked Then
    filter = "在校= True"
Else
    filter = "在校= false"
End If
If txt > "" Then
    txt = "\'%" & txt & "%\'"
    filter =" and 姓名 Like " & txt
End If
tbl.filter = filter


--  作者:digger_deng
--  发布时间:2015/10/7 16:33:00
--  
仍然是语法错误?


--  作者:大红袍
--  发布时间:2015/10/7 16:34:00
--  

 

[此贴子已经被作者于2015/10/7 16:34:53编辑过]

--  作者:digger_deng
--  发布时间:2015/10/7 16:37:00
--  
 仍然是语法错误?

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim chk As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim tbl As Table = Tables("学生档案")

Dim filter As String
If chk.checked Then
    filter = "在校= True"
Else
    filter = "在校= false"
End If
If txt > "" Then
    txt = "\'%" & txt & "%\'"
    filter =" and 姓名 Like " & txt
End If
tbl.filter = filter


filter变量后面的语句刷新为"" and 姓名 Like " & txt " ,并不是两个并列条件?


--  作者:大红袍
--  发布时间:2015/10/7 16:38:00
--  

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim chk As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim tbl As Table = Tables("学生档案")

Dim filter As String
If chk.checked Then
    filter = "在校= True"
Else
    filter = "在校= false"
End If
If txt > "" Then
    txt = "\'%" & txt & "%\'"
    filter &=" and 姓名 Like " & txt
End If
tbl.filter = filter


--  作者:digger_deng
--  发布时间:2015/10/7 16:41:00
--  
这段代码是对的,非常感谢!