Need help with Combobox code

ctark

Senior member
Sep 6, 2004
726
1
0
I'm updating our USMT GUI here at work and one feature I wanted to add was a drop down list of user names. Best way i thought to get this was just have a combo box and to pull the names from the C:\Users folder. I dont need the box to do anything else but list the names. Can someone help me out?
 

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
I could do this in VBA, not sure if it translates to VB though.

Code:
Dim fname As String, someCBO As ComboBox, searchInt As Integer

Set someCBO = ComboBox1 'replace this with the combo box

someCBO.Style = fmStyleDropDownList

'Clear an already populated list
For searchInt = 1 To someCBO.ListCount
    someCBO.RemoveItem 0
Next searchInt

fname = Dir$("c:\users\", vbDirectory)
While fname <> ""
    If InStr(fname, ".") = 0 Then
        someCBO.AddItem fname
    End If
fname = Dir$()
Wend
 
Last edited: