表结构 
序号 姓名 成绩 
1 张三 80 
2 李四 90 
3 王五 85 在vb窗体中循环以上表,循环出姓名,然后点击姓名,自动创建一个窗体,窗体内显示成绩, 
请各位高手帮忙

解决方案 »

  1.   

    用表格控件显示数据
    Dim cn As New ADODB.Connection
    Dim rs  As New ADODB.Recordset
    Private Sub Form_Load()
      cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据库名.mdb;Persist Security Info=False"
      rs.Open "select * from 表名", cn, adOpenKeyset, adLockOptimistic
      Set MSHFlexGrid1.DataSource = rs
      rs.Close
      cn.Close
    End Sub
      

  2.   


    '窗体上放一个 Visible 属性 = False 的 ListBox, 两个 Lable 和 一个 Timer:Private Sub Form_Load()
    Dim cn As New ADODB.Connection
    Dim rs  As New ADODB.Recordset
      cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据库名.mdb;Persist Security Info=False"
      Set rs = cn.Execute("Select 姓名, 成绩 From 表")  Do Until rs.EOF
        List1.AddItem rs!姓名
        List1.ItemData(List1.NewIndex) = rs!成绩
      Loop  Set rs = Nothing
      cn.Close
      Set cn = Nothing
      
      If List1.ListCount Then
        List1.ListIndex = 0
        Label1 = List1.List(List1.ListIndex)
      End If
      
      Label1.AutoSize = True
      Label1.Font.Size = 48
      Label2.AutoSize = True
      Label2.Font.Size = 72
      Label2.Font.Name = "Arial"
      
      Label2.Visible = False
      Timer1.Interval = 800
      Timer1.Enabled = True
    End Sub
    Private Sub Label1_Click()
      Label2 = List1.ItemData(List1.ListIndex)
      Label2.Visible = True
      Label2.ForeColor = IIf(Label2 >= "85", vbRed, vbBlack)
      Timer1.Enabled = False
      Timer1.Interval = 3000
      Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()  If Timer1.Interval > 800 Then
        Label2.Visible = False
        Timer1.Enabled = False
        Timer1.Interval = 800
        Timer1.Enabled = True
      End If  If List1.ListIndex < List1.ListCount - 1 Then
        List1.ListIndex = List1.ListIndex + 1
      Else
        List1.ListIndex = 0
      End If
      Label1 = List1.List(List1.ListIndex)
    End Sub
      

  3.   

    dim newtable as dao.tabledef
    dim mydb as dao.database
    for each newtable in mydb.tabledef
    '做你想做的
    next
    mydb.close
      

  4.   

    这是一个典型的数据form,vb中可用数据导航器直接生成这样的窗体和代码
      

  5.   

    for each in forms
    ...