艾利漫画r18艾伦黑化:关于VB逻辑表达式的问题,请高手指点

来源:百度文库 编辑:中科新闻网 时间:2024/04/20 04:25:06
a=1
If a <> "" Then
Where = Where & "and a = " & a
Where = Mid(Where, 5, Len(Where))
sqlstr = "select count(*) from book where "& Where
End sub
中间那三条语句是什么意思?谢谢
where=""

Where = Where & "and a = " & a
'用 & 连接where 和 "and a="这个字符串,并在最后加上 a的值

Where = Mid(Where, 5, Len(Where)) 'mid 是一个函数
'MSDN上的解释:从一个字符串返回包含指定数量字符的字符串。详细请看http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vblr7/html/vafctmid.asp

'Mid(Where, 5, Len(Where)) 是取得where这个字符串第5位及以后的字符,作用是去掉前面4位字符["and "]
sqlstr = "select count(*) from book where "& Where
'生成一个字符串,功能应该是统计book表中 符合"a = " & a 这个条件的记录个数

Where = Where & "and a = " & a
就是指假如WHERE的值是"地址"那么结果变成"地址and a =1"
第二句是从第5个字开始选长度为WHERE的STRING估计出错
第3句也是赋值,为读数据库准备

Where和sqlstr应该是string吧

if a<>""
sqlstr的值是 "select count(*) from book where a=1"

谁编的真是垃圾程序

语句 Where = Where & "and a = " & a 中
&是连接符
整体来说是一个赋值语句,即给Where赋值
Where & "and a = " & a的意思是
Where + "and a =" + a