vb 代码 求翻译
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub
答案:先声明下我是没学过vb的,我是学asp.net的。但是代码基本上可以帮你解释下
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)//行选项改变事件
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)//取DataGrid1的第一行的的Bookmark这个字段的值
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)//取DataGrid1的第八行的Bookmark这个字段的值
End Sub //命令结束
Private Sub Form_Load()//窗体加载
Dim rs_find As New ADODB.Recordset//实例化ADODB.Recordset对象 命名为rs_find
Dim sql As String //声明一边变量 变量名为sql
sql = "select * from 图书类别" //给变量sql赋值
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic//打开数据连接
rs_find.MoveFirst //下面的应该是vb对数据连接的操作。
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub
上一个:vb程序设计 求救 SOS
下一个:vb 压缩保存图片?