By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,644 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,644 IT Pros & Developers. It's quick & easy.

Display values in a ComboBox?

P: 4
Hello, I am a complete newbie with VB, so this question might sound really stupid; please bear with me.

My question is, can a combo box be used to display a value in the sense a label can?

I have developed a piece of hardware (PIC based) that I have connected to the PC over the serial port. Now, I get time from the PIC in an HH:MM format, which I would like to display in 2 combo boxes with dropdown lists; is this possible? Try as I might, I have not been able to do this, although of course I can successfully display those values in a label.

The reason I would like to display them in the combo list is that I would like to be able to change the value (using hours and minutes from the 2 combos with dropdown lists for hours and minutes) and write back into the PIC; this second part I think I can achieve, if I manage to get the original problem sorted.

Is this possible at all? Can one write to a combo list?

I would really appreciate any advise here.

Thanks and Regards,

Dec 21 '07 #1
Share this Question
Share on Google+
8 Replies

Expert 5K+
P: 8,127
to items to the combobox try this

combo1.additem "item to add"

hope that helps you in solving problem.
Dec 21 '07 #2

P: 4
Thanks for the prompt reply, Debasis.

I get a "Method or data member not found".

I'm sure I'm doing something intrinsically foolish here .....

Suppose doing runtime, I get a vale of,say, 10, for a variable.

How do I get the combobox to show the '10'?

STARTHR.AddItem 10 or STARTHR.AddItem "10" both give me the above error.


Dec 21 '07 #3

Expert 5K+
P: 8,127
Are you sure STARTHR is a combobox only , not any other control ?
Dec 21 '07 #4

P: 4
Yes it is. But, I had copied and pasted this from something I had written a *long* time ago, and I think its an array; the properties shows the name as STARTHR(0).

Does this make sense? How can I change this to be a simple non-array?


Dec 21 '07 #5

Expert 5K+
P: 8,127
try this

STARTHR(0).Additem "10"
Dec 21 '07 #6

P: 4
Thanks, the error has gone; but the value still doesnt show up in the combo box.

I guess I need to understand things more before I return, I don't want to use up more of your time.

Again, thanks a lot.


Dec 21 '07 #7

Expert 5K+
P: 8,434
What version of VB are you using?
Dec 21 '07 #8

P: 5
If you are using vb express 2005 they changed the format. combobox1.items.add "add your string here"

If you wish to display as per a text or label. Add the item then use combobox1.text = "The same string as before"

Dec 21 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.