473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

adding stuff to a combobox

dfg
Hi everyone. I am having a problem reading the contents of a file into
a ComboBox. I end up with only the last item being read into the list.
Can someone show me what is wrong?

Thanks.

test.txt contents:
"1994 Ford F150 Pickup"
"1987 GMC 2500"
"1986 Hyundai Pony"
"1996 Honda Civic"
"1990 Pontiac Sunfire"

My Code is as follows:

Private Sub Form_Load()
Dim intRetVal As Integer
Dim strEntries As String

On Error GoTo FileError
Open "a:\test.txt" For Input As #1

Do Until EOF(1)
Input #1, strEntries
cboVehicle.Text = strEntries 'How can i add to the box?
Loop

Exit Sub

FileError:
If Err.Number = 71 Then
intRetVal = MsgBox("Disk Not Ready", vbExclamation + vbOKCancel, _
"File Access Error")
If intRetVal = vbCancel Then
Unload Me
Else
Resume
End If
Else
Err.Raise Err.Number
End If

End Sub

Jul 17 '05 #1
1 2962
hfile = freefile
open xxxx etc as #hfile

do while not eof(hfile)

input #hfile, buff
combo1.additem buff

loop

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
"dfg" <df*@dfg.net> wrote in message
news:knfsb.371583$6C4.176195@pd7tw1no...
: Hi everyone. I am having a problem reading the contents of a file into
: a ComboBox. I end up with only the last item being read into the list.
: Can someone show me what is wrong?
:
: Thanks.
:
: test.txt contents:
: "1994 Ford F150 Pickup"
: "1987 GMC 2500"
: "1986 Hyundai Pony"
: "1996 Honda Civic"
: "1990 Pontiac Sunfire"
:
: My Code is as follows:
:
: Private Sub Form_Load()
: Dim intRetVal As Integer
: Dim strEntries As String
:
: On Error GoTo FileError
: Open "a:\test.txt" For Input As #1
:
: Do Until EOF(1)
: Input #1, strEntries
: cboVehicle.Text = strEntries 'How can i add to the box?
: Loop
:
: Exit Sub
:
: FileError:
: If Err.Number = 71 Then
: intRetVal = MsgBox("Disk Not Ready", vbExclamation + vbOKCancel,
_
: "File Access Error")
: If intRetVal = vbCancel Then
: Unload Me
: Else
: Resume
: End If
: Else
: Err.Raise Err.Number
: End If
:
: End Sub
:
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DraguVaso | last post by:
Hi, I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the Items-list, I want to add some values, based on a user choise (via a filter on the DataSource). Does anybody know...
4
by: Keith Smith | last post by:
I am reading this article... http://www.codeproject.com/cs/combobox/csautocomplete.asp About half-way down you will see a section titled "Using This Control" (written in orange lettering). ...
3
by: Raghavendra Mudugal | last post by:
Hello, I have two forms (Form1 and Form2) . Form1 contains one Combobox and a button which calls the second form on on_click event. In second form I have a textbox and a button. on click of...
5
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
1
by: Marco Roberto | last post by:
Hi, is there anyway to add itens into a combobox after this control be bound with a dataset? Regards, Marco
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
0
by: marcobx | last post by:
I have a ComboBox and a List of objects to popolate items. I use the DataSource property and not the List collection: List<foolst = new List<foo>; //add elements into the list //......
2
by: spowel4 | last post by:
Here's my code thus far: Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objxmldoc As New Xml.XmlDataDocument() 'Load all customer numbers...
34
by: bitsnbytes64 | last post by:
Hi, I've been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.