The vb.net application I'm developing is for data input and have utilised a combo box which is populated with a list of UK towns.
As it is 45,000 lines long there are problems testing the application as it doesn't always run when using the standard F5 - Start debugging a problem which doesn't occur when I removed the code to populate the combox box.
Code below populates the combo box:-
'StreamReader to read towns from a text file Dim townfile As New System.IO.StreamReader(Application.StartupPath + "\towns.txt", System.Text.Encoding.Default) ' Read file until no more data exists . i.e. BLANK LINE found Do While townfile.Peek <> -1 Dim LineIn As String = townfile.ReadLine() cboTown.Items.Add(LineIn) Loop
I did look at other solutions like loading the data into an Array, Stringbuilder, list and looking at I could use a buffer somehow.
I did try to use an 1d string array and use the streamReader ReadtoEnd mnethod but I couldn't get the conversion types right :-(
Any ideas how I make the process more efficent to populate a combo box with 45,000 + items?
PS I'm a vb.net newbie