Snowstorm Posted November 21, 2002 Share Posted November 21, 2002 Hey all :) I need to know how I can make a program load a text file with a list of words into a Combo box. For example in the text file, it has One Two Three Then after I started the program, One, Two, and Three would be in the combo box. Thanks. :ninja: Link to comment Share on other sites More sharing options...
0 Tobbe Posted November 21, 2002 Share Posted November 21, 2002 Here: Open "C:\Textfile.txt" For Input As #1 Do While EOF(1) = False Line Input #1, sInput Combo1.AddItem sInput Loop Close #1 Don't forget: Dim sInput As String My textfile looked like this: OneTwo Three Link to comment Share on other sites More sharing options...
0 Snowstorm Posted November 21, 2002 Author Share Posted November 21, 2002 Ooohh, cool, thanks! :) But one last thing, I've have a command button, and a text box, now when you type say, Four into it, it adds Four to the textfile under Three. :wacko: Link to comment Share on other sites More sharing options...
0 Tobbe Posted November 21, 2002 Share Posted November 21, 2002 Open "C:\Textfile.txt" For Append As #1 Print #1, Text1.Text Close #1 Link to comment Share on other sites More sharing options...
0 pringlex Posted November 21, 2002 Share Posted November 21, 2002 That's because it's just tagging it on the end of the file. Unless you can write a piece of code to sort the words into ascending order (not alphabetical order) the best bet would be to use numbers in the file instead of words - then I believe you can get the combo box to auto-sort the items. Link to comment Share on other sites More sharing options...
0 kyo116 Posted November 26, 2002 Share Posted November 26, 2002 yup, just set the sorted property to true. Link to comment Share on other sites More sharing options...
Question
Snowstorm
Hey all :)
I need to know how I can make a program load a text file with a list of words into a Combo box.
For example in the text file, it has
One
Two
Three
Then after I started the program, One, Two, and Three would be in the combo box.
Thanks. :ninja:
Link to comment
Share on other sites
5 answers to this question
Recommended Posts