谁能帮忙注释一下这个vb程序啊 真的非常感谢 谢谢!!!

2025-03-02 03:13:55
推荐回答(1个)
回答1:

'这一段是查询,并显示(单击事件)
Private
Sub
cmdQuery_Click
(
)
'定义了两个字符串,用于连接成一个字符串,作为BuildingQueryResult.Adodc1.RecordSource显示
Dim
strFilter
As
String,strSQL
As
String
'在连接好的数据库里查询各项数值,并连接到strfiter里
strFilter=”门牌号LIKE”’&Trim(txtDoorNumber)&”%’and
户主LIKE”’_
&txtHouseHolder&”%’and
土地号LIKE”’&txtLandNumber_
&”%’and
产权号LIKE’’’&txtPopertyNumber&”%’and”_
&’’户型LIKE’’’&cmbTypeList&”%’’’_
&’’and出售=’’&chkSale.Value&’’and
出租=“&chkLend.Value
StrSQL=”SELECT*FROM
楼盘数据
WHERE”&strFilter
'.....显示查询结果
BuildingQueryResult.Adodc1.CommandType=adCmdText
BuildingQueryResult.Adodc1.RecordSource=strSQL
BuildingQueryResult.Adodc1.Refresh
BuildingQueryResult.Show
End
Sub
Private
Sub
Adodc1_MoveComplete(ByVal
adReason
As
EventReasonEnum,_
ByVal
pError
As
Error,adStatus
As
EventStatuaEnum,_
ByVal
pRecordset
As
Recordset)
'with...end
with
其作用里可以省略adodc1.recordset,使代码简洁
With
Adodc1.Recordset
'如果查询到的数据项为大于0,也就是说有查到
If
.Absoluteposition>0
Then
'那么在adodc1里显示”查询结果:”&.AbsolutePosition&”/”&.RecordCount
Adodc1.Caption=”查询结果:”&.AbsolutePosition&”/”&.RecordCount
'如果没查到数据,那么就显示"查询结果"........注意,后面没有
&”/”&.RecordCount
'再说明一下,后面好像少了一个"&"(字符串连接符),不知道你运行时有没有出错呢
Else:Adodc1.Caption=”查询结果”
End
If
End
With
End
Sub
'这一段是清除各项数据了,查询完之后清除
'因为跟你定义变量的库文件有关,就不一一说明了
Private
Sub
cmdClear_Click()
txtDoorNumber=””
txtHouseHolder=””
txtLandNumber=”

txtPopertyNumber=”

cmbTypeList.Text=”“
chkLend.Value=0
chkSale.Value=0
End
Sub
'这一段的作业是关闭程序
Private
Sub
cmdExit_Click()
Unload
Me
‘关闭查询楼盘数据窗体
End
Sub