Private Sub Form_Load()Call DataBase sql = "Select 姓名,年龄 From 通讯" adoRs.Open sql,adoCon,1,3 adoRs.MoveFirstEnd SubPrivate Sub Form_Activate()ReDim lb(adoRs.RecordCount) ReDim tx(adoRs.RecordCount)For i = 0 To adoRs.RecordCount - 1Set lb(i) = Me.Controls.Add("vb.label","mylbhd" & i)lb(i).Top = 200 + i * 500lb(i).Left = 100lb(i).BackColor = RGB(100,150,200) lb(i).Visible = True Set tx(i) = Me.Controls.Add("vb.textBox","mytx" & i)mLeft = 100mTop = 200tx(i).Top = 200 + i * 500tx(i).Left = 1400tx(i).BackColor = RGB(100,200)tx(i).Visible = TrueNextadoRs.MoveFirsti = 0Do Until adoRs.EOFtx(i).text = adoRs.Fields("年龄") lb(i).Caption = adoRs.Fields("姓名") Next i = i + 1adoRs.MoveNextLoop adoRs.Close: Set adoRs = Nothing adoCon.Close: Set adoCon = NothingEnd Sub
原文链接:https://www.f2er.com/vb/263183.html