Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

comboBox

Hi All,

I am trying to create a straight forward combobox with 2 options: UK and Ireland.

I have not dont a combo box and i have no idea how go create one, all i have done so far is place a combobox on screen:

Private Sub Combo1_Change()

End Sub

Could anyone point me in the right direction? :confused:
[348 byte] By [mp_direct] at [2007-11-11 7:18:35]
# 1 Re: comboBox
The first place to look to learn about combo boxes is the Index of the Help Menu of your VB module, msdn. Some of the things to look at would be the
List, List Count, and List Index Properties; the Add Item, Clear, and Remove Item Methods. I have found that the Click Event is much more helpful that the change event that you show. A combo box, like a list box, has to have items added through the add item method before most other events have any meaning. Where you place the add item method will be determined by your
project.
jnesbett at 2007-11-11 17:27:08 >
# 2 Re: comboBox
Thanks, but i do not have msdn installed?
mp_direct at 2007-11-11 17:28:08 >
# 3 Re: comboBox
Well, install it then! ;-) MSDN is also available online at http://msdn.microsoft.com/library . In the Table of Contents, drill down to Development Tools and Languages -> Visual Studio 6.0 -> Visual Basic 6.0 -> Product Documentation -> Reference. Here's a direct link to the ComboBox page: http://msdn.microsoft.com/library/en-us/vb98/html/vbobjComboBox.asp
Phil Weber at 2007-11-11 17:29:09 >
# 4 Re: comboBox
Hi All,
in my code i am loading the following values:
ComboCountry.AddItem "UK", 0
ComboCountry.AddItem "Republic of Ireland", 1
Can someone help me do the folloing? i bit stuck

if case index =0 then
set currency to pounds
if case index = 1 then
set currency to euros

Any thoughts
mp_direct at 2007-11-11 17:30:14 >
# 5 Re: comboBox
If ComboCountry.ListIndex = 0 Then...
Phil Weber at 2007-11-11 17:31:13 >
# 6 Re: comboBox
You could also just look for the combo.text property.
Feldhege at 2007-11-11 17:32:12 >
# 7 Re: comboBox
If ComboCountry.SelectedIndex = 0 Then...

did you mean ListIndex? SelectIndex is a .NET property

Marco
mstraf at 2007-11-11 17:33:12 >
# 8 Re: comboBox
Yes, sorry. I work with .NET much more than VB6 these days.
Phil Weber at 2007-11-11 17:34:15 >
# 9 Re: comboBox
Here is how I would do that.

Set the Style Property to "2- Dropdown list"

ComboCountry.Clear
ComboCountry.AddItem "UK"
ComboCountry.AddItem "Republic of Ireland"

If you want to preset the choice use
ComboCountry.text = "UK"

Then Check the result using the text Property
Select Case ComboCountry.text
Case "UK"
set currency to pounds
Case "Republic of Ireland"
set currency to euros
end select

Robb
Feldhege at 2007-11-11 17:35:13 >
# 10 Re: comboBox
Yes, sorry. I work with .NET much more than VB6 these days.

What is the best way to get started using .net after all these years of VB6?
I have VS 2003 and have never installed it. Looks like I will have to start soon. Any tips?

Robb Feldhege
feldhege@mindspring.com
Feldhege at 2007-11-11 17:36:24 >