Private Sub CmdCx_Click()
Dim strwhere As String
strwhere = " where 1=1" ???
If ChkNo.Value = 1 Then
strwhere = strwhere & " and 图书编号 like '%" & Trim(TxtNo.Text) & "%'"
End If
If ChkAuthor.Value = 1 Then
strwhere = strwhere & " and 作者 like '%" & Trim(TxtAuthor.Text) & "%'"
'strwhere = " 作者 like '%" & Trim(TxtAuthor.Text) & "%'"
End If
end sub这是复选框的一段代码,功能高手一看就知了,就不解释了!
问题是 strwhere = " where 1=1" 这句怎么理解的,为什么用1=1?
先谢了!
Dim strwhere As String
strwhere = " where 1=1" ???
If ChkNo.Value = 1 Then
strwhere = strwhere & " and 图书编号 like '%" & Trim(TxtNo.Text) & "%'"
End If
If ChkAuthor.Value = 1 Then
strwhere = strwhere & " and 作者 like '%" & Trim(TxtAuthor.Text) & "%'"
'strwhere = " 作者 like '%" & Trim(TxtAuthor.Text) & "%'"
End If
end sub这是复选框的一段代码,功能高手一看就知了,就不解释了!
问题是 strwhere = " where 1=1" 这句怎么理解的,为什么用1=1?
先谢了!
你也可以初始化成strwhere=""
然后每次判断如果strwhere=""就是strwhere="……" 否则是strwhere= strwhere & "……"
这样就麻烦了