COMBO Boxes

Please help me.
I need to display a list of country names. But after the user select the country name, I just want to assign the country code eg. AFG for Afghanistan, IND for India to a text field. I will be loading this data from a table where the country code and country names are stored.
Please help.
Thank you for your help.
May God bless you.

Comments

  • : Please help me.
    : I need to display a list of country names. But after the user select the country name, I just want to assign the country code eg. AFG for Afghanistan, IND for India to a text field. I will be loading this data from a table where the country code and country names are stored.
    : Please help.
    : Thank you for your help.
    : May God bless you.
    :
    :
    Use the ItemData property and put the country code in the ItemData property of each List item.

    I think this is what you want and I modified the following example right from the VB Help:


    [code]Private Sub Form_Load ()
    ' Fill List1 and ItemData array with
    ' corresponding items in sorted order.
    List1.AddItem "United States"
    List1.ItemData(List1.NewIndex) = "USA"
    List1.AddItem "India"
    List1.ItemData(List1.NewIndex) = "IND"
    List1.AddItem "Afganistan"
    List1.ItemData(List1.NewIndex) = "AFG"
    End Sub

    Private Sub List1_Click ()
    strCountryCode = List1.ItemData(List1.ListIndex)
    End Sub[/code]


  • [b][red]This message was edited by lionb at 2002-10-18 13:2:0[/red][/b][hr]
    : [code]Private Sub Form_Load ()
    : ' Fill List1 and ItemData array with
    : ' corresponding items in sorted order.
    : List1.AddItem "United States"
    : List1.ItemData(List1.NewIndex) = "USA"
    : List1.AddItem "India"
    : List1.ItemData(List1.NewIndex) = "IND"
    : List1.AddItem "Afganistan"
    : List1.ItemData(List1.NewIndex) = "AFG"
    : End Sub
    :
    : Private Sub List1_Click ()
    : strCountryCode = List1.ItemData(List1.ListIndex)
    : End Sub[/code]
    :
    Hi James. Are you sure this is correct example? I think ItemData is integer ... well may be I am wrong
    :



  • : [b][red]This message was edited by lionb at 2002-10-18 13:2:0[/red][/b][hr]
    : : [code]Private Sub Form_Load ()
    : : ' Fill List1 and ItemData array with
    : : ' corresponding items in sorted order.
    : : List1.AddItem "United States"
    : : List1.ItemData(List1.NewIndex) = "USA"
    : : List1.AddItem "India"
    : : List1.ItemData(List1.NewIndex) = "IND"
    : : List1.AddItem "Afganistan"
    : : List1.ItemData(List1.NewIndex) = "AFG"
    : : End Sub
    : :
    : : Private Sub List1_Click ()
    : : strCountryCode = List1.ItemData(List1.ListIndex)
    : : End Sub[/code]
    : :
    : Hi James. Are you sure this is correct example? I think ItemData is integer ... well may be I am wrong
    : :
    Noop I was correct. Yor example is not quite correct.
  • : : [b][red]This message was edited by lionb at 2002-10-18 13:2:0[/red][/b][hr]
    : : : [code]Private Sub Form_Load ()
    : : : ' Fill List1 and ItemData array with
    : : : ' corresponding items in sorted order.
    : : : List1.AddItem "United States"
    : : : List1.ItemData(List1.NewIndex) = "USA"
    : : : List1.AddItem "India"
    : : : List1.ItemData(List1.NewIndex) = "IND"
    : : : List1.AddItem "Afganistan"
    : : : List1.ItemData(List1.NewIndex) = "AFG"
    : : : End Sub
    : : :
    : : : Private Sub List1_Click ()
    : : : strCountryCode = List1.ItemData(List1.ListIndex)
    : : : End Sub[/code]
    : : :
    : : Hi James. Are you sure this is correct example? I think ItemData is integer ... well may be I am wrong
    : : :
    : Noop I was correct. Yor example is not quite correct.
    :
    Oops! My bad! I never use MS Combos anyway--for this very reason. I use a third party combo that can have multiple columns in the drop-down and you can choose which one you want for display, etc. I guess I should have tested my example. Ha!

    James
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories