Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate the dropdownlist combobox from a text file

Status
Not open for further replies.

bizzzzzzz

Technical User
Jan 20, 2005
15
CA
HI

I put a list in a text file, like this

dog
cat
horse
rabit

i have 12 combobox where i want to retreive this information
from the dropdown menu.
is exit a path to directly add the list in the combo1.list fields?

Thanks

Eric
 
bizzzzzzz,

This is example that uses one text file and one combobox:

Option Explicit

Private mobjFSO As New FileSystemObject
Private mobjTextStream As TextStream

Private Sub Command1_Click()

Combo1.Clear

Set mobjTextStream = mobjFSO.OpenTextFile("T:\MyList.txt", ForReading, False, TristateUseDefault)

While Not mobjTextStream.AtEndOfStream
Combo1.AddItem mobjTextStream.ReadLine
Wend


End Sub

Private Sub Form_Unload(Cancel As Integer)
Set mobjFSO = Nothing
Set mobjTextStream = Nothing
End Sub

You will need to set reference in your project to Microsoft Scripting Runtime library first.

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top