For Index =1 To 3
Load txtRkzd(Index)
txtRkzd(Index).Top = txtRkzd(0).Height
txtRkzd(Index).Left = txtRkzd(Index-1).Left+txtRkzd(index).width
txtRkzd(Index).Visible = True
Next
引用ADO(Microsoft ActiveX Data Objects 2.X Library)
Dim myImg() As Image
Private Sub Command1_Click()
On Error GoTo err
Dim cn As New ADODB.Connection, rs
'连接SQL:
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=登陆用户名;Password=登录密码;Initial Catalog=数据库名;Data Source=yourSERVICE"
'连接Access:
'cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Test.mdb;Jet OLEDB:DataBase password=12345;""
cn.Open
rs.CursorLocation=adUseClient'设置客户端游标
rs.Open "select * from 表1", cn, 3, 2
If rs.Eof Then
Exit Sub
rs.Close
cn.Close
Set rs=Nothing
Set cn=Nothing
End If
ReDim myImg(rs.RecordCount-1)
dim i%
for i=0 to rs.RecordCount-1
Set myImg(i) = Form1.Controls.Add("vb.Image", "img" & i & "")
myImg(i).Width=20:myImg(i).Height=20
myImg(i).Left = 100 + 100 * i
myImg(i).Top = 100 + 500 * i
myImg(i).Visible = True
'myImg.BorderStyle=1
next
rs.Close
cn.Close
Set rs=Nothing
Set cn=Nothing
Exit Sub
err:
MsgBox err.Description
End Sub