Private Sub FillUsers(ByVal oList As ListBox, ByVal nAuthority As Integer)
    Dim oRead As New CUserRead
    Dim oRS As ADODB.Recordset
    Dim sName As String
    Dim lID As Long
    
    Set oRS = oRead.GetUserList("UserRight=" & nAuthority)
    If oRS Is Nothing Then
        Alert "Common Database Error!"
    Else
        With oRS
            If .EOF = True And .BOF = True Then
'                Alert "No User Found!!"
            Else
                .MoveFirst
                Do While Not .EOF
                    sName = .Fields("UserName").Value
                    lID = .Fields("MainID").Value
                    'nAuthority = .Fields("UserRight").Value
                    If UCase(sName) <> "ADMINISTRATOR" Then
                        With oList
                            .AddItem sName
                            .ItemData(.NewIndex) = lID
                        End With
                    End If
                    .MoveNext
                Loop
            End If
        End With
    End If
End Sub

解决方案 »

  1.   

    listbox显示数据库中表的一个字段的全部内容?没有滚动显示不下只有自己添加一text控件显示当前数据.
    listbox当前数据参照 回复人: nik_Amis(Azrael)  listview
       lv.ListItems.Clear
       lv.ColumnHeaders.Clear
       lv.View = lvwReport
       lv.LabelEdit = lvwManual
       '
       ' Fill 10 column headers with random crud.
       '
       Set clm = lv.ColumnHeaders.Add(, , "$#,##0.00")
       Set clm = lv.ColumnHeaders.Add(, , "0")
    ...
       For i = 1 To nItems
          Set itm = lv.ListItems.Add(, "Row" & i, Format(Rnd * 100000, "$#,##0.00"))
          itm.SubItems(1) = Format(Rnd * 100000, "0")
          itm.SubItems(2) = Format(Rnd * 100000, "#,##0")
          itm.SubItems(3) = Format(Rnd * 100000, "#,##0.0000")
          itm.SubItems(4) = Format(CDate(Rnd * 100 + Now), "short date")
    ...
       Next i