|
-
May 17th, 2006, 11:08 PM
#1
help with combobox
dear,
how to add the item
Code:
combobox1.AddItem "1"
this code cannot do that.
-
May 17th, 2006, 11:29 PM
#2
Re: help with combobox
Hi,
Check whether the name of your combo box is combobox1.
The default name is Combo1.
To add with it, use
-
May 18th, 2006, 12:01 AM
#3
Re: help with combobox
thank you. but i rename the combobox as combobox1, and want to add a new item to exsiting items. but use such code cannot archieve that, help me.
-
May 18th, 2006, 12:16 AM
#4
Re: help with combobox
Hi,
Post your project here.
-
May 18th, 2006, 12:22 AM
#5
Re: help with combobox
Hi
Just tried it out, works fine.
Code:
Dim j as integer
Private Sub Form_Load()
Combobox1.Clear
For J = 1 To 10
Combobox1.AddItem J
Next J
Combobox1.Text = Combobox1.List(0)
End Sub
Cheers
Karsten
-
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
|