VB代码翻译

由于要答辩,请帮我详细解释下面这段代码,最好能够逐行解释,多谢了,大家帮帮忙啊!
Private Sub ComdQuery_Click()
Dim SqlStr As String
Dim rsCheck As New Recordset
Dim sRoomID As String
Dim sMemberID As String
Dim dOTime As String

sRoomID = Trim(Me.CombRoomID.Text)
sMemberID = Trim(Me.CombMemberID.Text)

dOTime = Trim(Me.DTPicker1.Value)

SqlStr = "select CheckID as 帐单编号,OpenDate as 开房日期" & ",MemberID as 会员编号,ClientName as 客户姓名" & ",RoomID as 房间编号,RoomType as 房间类型" & ",RoomPrice as 房间价格,OpenRoomTime as 开房时间" & ",EndTime as 结束时间,Prepay as 预付金额" & ",Agio as 折扣,PayMode as 付款方式,RoomMoney as 消费金额 " & "from CheckInfo where RoomID like " & "" & " '%" & sRoomID & "%'" & "and MemberID like " & "'%" & sMemberID & "%'" & "and OpenDate ='" & dOTime & "'"

Set rsCheck = Conn.Execute(SqlStr)

Set DataGrid1.DataSource = rsCheck

Set rsCheck = Nothing
End Sub

Private Sub Form_Load()
Me.Top = (Screen.Height - Me.Height) / 2 '垂直方向居中
Me.Left = (Screen.Width - Me.Height) / 2 '水平方向居中

With Conn
Conn.CursorLocation = adUseClient
Conn.CommandTimeout = 10
Conn.ConnectionString = g_ConnStr
Conn.Open

End With

Dim SqlStr As String
Dim rsDestine As New Recordset

SqlStr = "select CheckID as 帐单编号,OpenDate as 开房日期" & ",MemberID as 会员编号,ClientName as 客户姓名" & ",RoomID as 房间编号,RoomType as 房间类型" & ",RoomPrice as 房间价格,OpenRoomTime as 开房时间" & ",EndTime as 结束时间,Agio as 折扣,Prepay as 预付金额" & ",PayMode as 付款方式,RoomMoney as 消费金额 from CheckInfo"
Set rsDestine = Conn.Execute(SqlStr)
Me.DataGrid1.ColumnHeaders = True
Set DataGrid1.DataSource = rsDestine
Set rsDestine = Nothing

'从数据库中读取数据写入房间编号下拉列表框
Dim adoRs As New ADODB.Recordset
Dim DBStr As String
DBStr = "select RoomID from RoomInfo "
adoRs.Open DBStr, Conn, adOpenStatic, adLockReadOnly

If adoRs.RecordCount > 0 Then
adoRs.MoveFirst

Do While Not adoRs.EOF
CombRoomID.AddItem adoRs.Fields(0).Value
adoRs.MoveNext
Loop

End If

adoRs.Close
Set adoRs = Nothing

'从数据库中读取数据写入会员编号下拉列表框
Dim adoMemIDRs As New ADODB.Recordset
DBStr = "select MemberID from MemberInfo"
adoMemIDRs.Open DBStr, Conn, adOpenStatic, adLockReadOnly

If adoMemIDRs.RecordCount > 0 Then
adoMemIDRs.MoveFirst

Do While Not adoMemIDRs.EOF
CombMemberID.AddItem adoMemIDRs.Fields(0).Value
adoMemIDRs.MoveNext
Loop

End If

adoMemIDRs.Close
Set adoMemIDRs = Nothing

End Sub

Private Sub ComdQuery_Click() '查询 数据库表格 然后显示在 DataGrid1的 表格控件上
Dim SqlStr As String
Dim rsCheck As New Recordset
Dim sRoomID As String
Dim sMemberID As String
Dim dOTime As String '变量声明

sRoomID = Trim(Me.CombRoomID.Text)
sMemberID = Trim(Me.CombMemberID.Text) '变量=窗体控件上的数据 (赋值)
dOTime = Trim(Me.DTPicker1.Value)

'这个数据库表格字段名 是英文写的,因此 查询显示时需要将其变为中文 这样才直观看。 这些臭长臭长 As 都是变换呢 后面的 Where 后面的句子 是条件语句 按照 房间号 啊 日期啊等等做条件来查的。
SqlStr = "select CheckID as 帐单编号,OpenDate as 开房日期" & ",MemberID as 会员编号,ClientName as 客户姓名" & ",RoomID as 房间编号,RoomType as 房间类型" & ",RoomPrice as 房间价格,OpenRoomTime as 开房时间" & ",EndTime as 结束时间,Prepay as 预付金额" & ",Agio as 折扣,PayMode as 付款方式,RoomMoney as 消费金额 " & "from CheckInfo where RoomID like " & "" & " '%" & sRoomID & "%'" & "and MemberID like " & "'%" & sMemberID & "%'" & "and OpenDate ='" & dOTime & "'"

Set rsCheck = Conn.Execute(SqlStr) '让SQL 连接执行刚才的语句。

Set DataGrid1.DataSource = rsCheck '让DataGrid1表格控件绑定检索返回 来显示到界面上。

Set rsCheck = Nothing '注销刚才的连接

End Sub

Private Sub Form_Load()
Me.Top = (Screen.Height - Me.Height) / 2 '垂直方向居中
Me.Left = (Screen.Width - Me.Height) / 2 '水平方向居中

With Conn
Conn.CursorLocation = adUseClient
Conn.CommandTimeout = 10
Conn.ConnectionString = g_ConnStr '打开数据库连接
Conn.Open

End With

Dim SqlStr As String
Dim rsDestine As New Recordset '和上面的一样

SqlStr = "select CheckID as 帐单编号,OpenDate as 开房日期" & ",MemberID as 会员编号,ClientName as 客户姓名" & ",RoomID as 房间编号,RoomType as 房间类型" & ",RoomPrice as 房间价格,OpenRoomTime as 开房时间" & ",EndTime as 结束时间,Agio as 折扣,Prepay as 预付金额" & ",PayMode as 付款方式,RoomMoney as 消费金额 from CheckInfo"
Set rsDestine = Conn.Execute(SqlStr)
Me.DataGrid1.ColumnHeaders = True
Set DataGrid1.DataSource = rsDestine
Set rsDestine = Nothing

'从数据库中读取数据写入房间编号下拉列表框
Dim adoRs As New ADODB.Recordset '不知道这代码谁写,一个连接就行了搞这么多
Dim DBStr As String '上面的查询完毕 关闭再连接就是了 这样搞 还要重新
DBStr = "select RoomID from RoomInfo " '声明变量 再连接, 吃饱了撑的。
adoRs.Open DBStr, Conn, adOpenStatic, adLockReadOnly
'如果需要我给你重写一下 这么长 其实都是一样的
If adoRs.RecordCount > 0 Then '只是查询的表不同吧了。
adoRs.MoveFirst

Do While Not adoRs.EOF '循环读取所有数据 然后添加到 名字叫 CombRoomID 的 ComboBox中
CombRoomID.AddItem adoRs.Fields(0).Value
adoRs.MoveNext '下一条 直道没有 就不Loop了
Loop

End If

adoRs.Close
Set adoRs = Nothing

'从数据库中读取数据写入会员编号下拉列表框
Dim adoMemIDRs As New ADODB.Recordset
DBStr = "select MemberID from MemberInfo" '这和前面的一样 变量名变变吧了。
adoMemIDRs.Open DBStr, Conn, adOpenStatic, adLockReadOnly

If adoMemIDRs.RecordCount > 0 Then
adoMemIDRs.MoveFirst

Do While Not adoMemIDRs.EOF
CombMemberID.AddItem adoMemIDRs.Fields(0).Value
adoMemIDRs.MoveNext
Loop

End If

adoMemIDRs.Close
Set adoMemIDRs = Nothing

End Sub
温馨提示:内容为网友见解,仅供参考
无其他回答

vb代码翻译
语言代码翻译 私人子表格_激活()。M _停止=错误 Form1.Reload 结束 私人子表格_ MouseDown(按钮,转变为整数作为一个整体,x,y为单)。2如果按钮 MMControl1.Command =“关”最后 如果年底 结束 私人子表格_ QueryUnload UnloadMode整型,如(取消)为整数,MMControl1.Command =“停止”MMControl1.Command ...

vb 代码翻译:
Option Explicit'不能使用隐匿变量Private perW As Long, perH As LongPrivate Row As Long, Col As LongPrivate numS As Long, numE As LongPrivate lastEndNum As Long'申请的变量 Private Sub cboCol_Click() Update'调用过程\/函数End SubPrivate Sub cboRow_Click() Update'同上End Sub...

VB代码翻译、
Dim d As Boolean '定义全局变量d,代表移动方向 Private Sub Form_Load() '程序启动时载入运行 Label1.Left = Me.Width - Label1.Width 'Label1移动到最靠窗体右边 Timer1.Interval = 100 '定时器设置为0.1秒 d = True '初始化d,方向向左 End Sub Private Sub Timer1_Timer()If...

用通俗的话把下面VB的代码翻译下。就相当于注释。
Private Sub Command2_Click()'单击Command2的事件代码 '功能:对选中的通讯记录进行删除 If ListView1.ListItems.Count > 0 Then '如果当前ListView中的列表项个数大于0,即不为空则 If MsgBox("真的要删除吗?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then '显示对话框询问是否...

vb 代码翻译
Static i As Integer '声明变量i If KeyCode = 13 Then '如果按下回车 If (Text1.Text) = "abcd" Then '如果Text1中的内容是abcd Label2.Caption = "你已成功进入" 'Label2显示 ElseIf i < 3 Then '如果i小于3 i = i + 1 'i增加1 MsgBox "口令错!请重新输入" '对话框 Text1....

vb代码翻译
Dim t0 as string, t1 as string '声明2个字符串变量t1,t2 if keyascii<> 13 then '如果按下的不是回车键 else '否则(按下了回车键)text2="" '清空Text2 n=1 '并给n赋值1 t0="." '给t0赋值"."t1= mid(text1,n,1) '将text1中从第n个字符之后的1个字符取出放入t1 Do while ...

vb 代码 逐句翻译一下 谢谢
Dim sql As String '定义存储sql语句的变量 If Check1.Value = vbChecked Then '如果复选框check1被选中,sql语句中读者编号等于text1的值 sql = "读者编号='" & Trim(Text1.Text & " ") & "'"End If If Check2.Value = vbChecked Then '同上 If Trim(sql) = "" Then ...

请高手翻译vb代码,谢谢
Private Sub Pic_Click() '单击picture Init '调用初始化函数 '下面的60000,为了测试我改为100 Timer3.Interval = 100 '设置计时器,60000=1分钟执行一次代码 Timer3.Enabled = True '计时器运行 End Sub Private Sub Init() '初始化函数 Dim i As Integer Pic.Cls '清画屏picture不为空 Pic....

vb代码翻译
endl是一个变量 chr()是一个函数,用户返回ASCII码对应的字符 chr(10)是换行,chr(13)是回车 msg每连接一个字符串就会加上一个换行和一个回车 然后输出到文本text1里 输出后是:床前明月光 疑是地上霜 举头望明月 低头思故乡

VB代码翻译
Dim sRoomID As String Dim sMemberID As String Dim dOTime As String '变量声明 sRoomID = Trim(Me.CombRoomID.Text)sMemberID = Trim(Me.CombMemberID.Text) '变量=窗体控件上的数据 (赋值)dOTime = Trim(Me.DTPicker1.Value)'这个数据库表格字段名 是英文写的,因此 查询显示时需...

相似回答
大家正在搜