Here is an example, add a ComboBox called Combo1 and a CommandButton called Command1.
Code:
Option Explicit
Private Sub Command1_Click()
AddComboBoxItem Combo1, "Item" & Val(Rnd * 100)
End Sub
Private Sub AddComboBoxItem(cbo As ComboBox, ByVal sItem As String)
Dim iFileNummer As Integer
Dim sCurrentitem As String
'open file
iFileNummer = FreeFile
Open App.Path & "\" & App.ProductName & "_" & cbo.Name & ".dat" For Append As iFileNummer
'Add item
Print #iFileNummer, sItem
'Close file
Close #iFileNummer
'Remeber what item we have currently selected
sCurrentitem = cbo.Text
'Re-read the values
ReadComboBox cbo
'Set item back to the one we had selected
On Error Resume Next
cbo.Text = sCurrentitem
End Sub
Private Sub ReadComboBox(cbo As ComboBox)
Dim iFileNummer As Integer
Dim sItem As String
'Clear ComboBox
cbo.Clear
'Open File
iFileNummer = FreeFile
Open App.Path & "\" & App.ProductName & "_" & cbo.Name & ".dat" For Input As iFileNummer
'Read items
Do Until EOF(iFileNummer)
Line Input #iFileNummer, sItem
'Add item to combobox
cbo.AddItem sItem
Loop
'Close File
Close iFileNummer
End Sub
Private Sub Form_Load()
ReadComboBox Combo1
End Sub