Saving combo items to a file

Here's some code to show you how to save some combo items to a file. This could be useful when creating a find history or favourites combo box. Please see 'Loading combo items from a file' for the code to re-load the data.

Private Sub SaveItems()
    Dim filenum As Integer
    Dim i As Integer

    filenum = FreeFile '// Get a free file number

    Open App.Path & "items.txt" For Output As filenum '// open the file
    For i = 0 To Combo1.ListCount - 1
        Print #filenum, Combo1.List(i) '// write each item to the file
    Next

    Close filenum '// Close the file
End Sub

You might also like...

Comments

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous