|
-
May 18th, 2006, 12:46 AM
#6
Re: help with combobox
 Originally Posted by liuyang
Hi
Just tried it out, works fine.
Code:
Dim j as integer
Private Sub Form_Load()
Combobox1.Clear '1
For J = 1 To 10
Combobox1.AddItem J
Next J
Combobox1.Text = Combobox1.List(0) '2
End Sub
Cheers
Karsten
Hi Karsten!
I noticed 2 things in your code:
1) You do not need to clear the combobox at form load - Form Load is fired when your form gets loaded into memory, so you can see Form Load as the firts event that fires for your form (in this case)
2) I also see that your For Loop starts at 1. Combobox's ListIndexes are 0 based, meaning that the first item in a combobox is 0, not 1 - so if you want to add 10 items to your combobox, you can start the loop at 0, and end it at 9.
just my 2 cents..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|