关于VB的编程!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/10 23:24:41
请朋友帮我翻译一下下面程序,请尽可能详细一点,最好每一步都要:
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_reader As New ADODB.Recordset
Dim sql As String
Set DataGrid1.DataSource = Adodc2
findform = True
Adodc2.RecordSource = "select * from Rooms where 教室房间号='" & Combo2.Text & "'"
Adodc2.Refresh
DataGrid1.ReBind
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
End Sub

Private Sub Form_Load()
Dim i As Integer
Combo1.Clear
Combo2.Clear
Set DataGrid1.DataSource = Adodc1
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields(1).Value
Combo2.AddItem Adodc1.Recordset.Fields(0).Value
Adodc1.Recordset.M

‘Combo1点击事件。
Private Sub Combo1_Click()
‘Combo2的列表索引=Combo1的列表索引
Combo2.ListIndex = Combo1.ListIndex
End Sub

‘Combo2点击事件。
Private Sub Combo2_Click()
‘Combo1的列表索引=Combo2的列表索引
Combo1.ListIndex = Combo2.ListIndex
End Sub

‘Command1点击事件。
Private Sub Command1_Click()
'定义一个数据链接对象
Dim rs_reader As New ADODB.Recordset
'定义一个字符串对象
Dim sql As String
'设定DataGrid1数据缘为Adodc2
Set DataGrid1.DataSource = Adodc2
‘findform等于真
findform = True
'设定Adodc2的数据查询字符串
Adodc2.RecordSource = "select * from Rooms where 教室房间号='" & Combo2.Text & "'"
’执行Adodc2刷新方法
Adodc2.Refresh
’执行DataGrid1的ReBind方法
DataGrid1.ReBind
’执行DataGrid1的AllowAddNew=假,可能是不允许添加新项目
DataGrid1.AllowAddNew = False
’执行DataGrid1的AllowDelete =假,可能是不允许删除项目
DataGrid1.AllowDelete = False
’执行DataGrid1的AllowUpdate =假,可能是不允许更新项目