VB中数据库给数组赋值 10
我在Form1中添加了一个Data控件连接数据库,想要将数据库中“线路”字段下的值赋值给组合框,但是每次运行,组合框Combo1中都是空值。请哪位高手帮我指点一下,代码如...
我在Form1中添加了一个Data控件连接数据库,想要将数据库中“线路”字段下的值赋值给组合框,但是每次运行,组合框Combo1中都是空值。请哪位高手帮我指点一下,代码如下:
Option Explicit
Option Base 1
public bname(15) As String
Sub main() '数据库给数组赋值
Dim i As Integer, Rdata As Object
Set Rdata = Form1.Data1
For i = 0 To 14
bname(i + 1) = Rdata.Recordset.Fields("线路")
Rdata.Recordset.Move 1
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 15
Combo1.AddItem bname(i), i - 1
Next i
End Sub 展开
Option Explicit
Option Base 1
public bname(15) As String
Sub main() '数据库给数组赋值
Dim i As Integer, Rdata As Object
Set Rdata = Form1.Data1
For i = 0 To 14
bname(i + 1) = Rdata.Recordset.Fields("线路")
Rdata.Recordset.Move 1
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 15
Combo1.AddItem bname(i), i - 1
Next i
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询