Ok, maybe I'm just stupid but........
This looks like it should work to me. The WriteTextFile part should loop through the listbox and write all of the items to a textfile. The ReadTextFile part should read the textfile and loop through adding each item to the combobox. This has worked somewhat, but all I get in my combo box on the Read part is "False". Is this because m is not dimmed as a string? Here's the events:
VB Code:
Public Sub ReadTextFile()
Dim lngFileNo As Long
Dim str As String
MusicMaster.ComboCategory.Clear
lngFileNo = FreeFile
Open "C:\Windows\System\categories.kmo" For Input As lngFileNo
Do While Not EOF(lngFileNo)
Line Input #lngFileNo, str
MusicMaster.ComboCategory.AddItem str
Loop
Close lngFileNo
End Sub
Public Sub WriteTextFile()
'Save the listbox entries to a text file
Dim l As Integer
Dim m As Integer
'get the next free file
l = FreeFile
Open "C:\Windows\System\categories.kmo" For Output As #l
'start the loop
For m = 0 To categories.lstCategories.ListCount - 1
'add to the file every line from the listbox
Print #l, categories.lstCategories.Selected(m)
Next m
Close #l
End Sub
I've never had this much trouble writing to a text file before. Any help appreciated.