Howdy, Stranger!

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

Categories

COMBO Boxes

amar_bajraamar_bajra Member Posts: 10
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

  • JamesJames Member Posts: 217
    : 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]


  • lionblionb Member Posts: 1,688 ✭✭
    [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
    :



  • lionblionb Member Posts: 1,688 ✭✭
    : [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.
  • JamesJames Member Posts: 217
    : : [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
  • Shawn CarterShawn Carter Member Posts: 0

    ( http://forcoder.org ) free video tutorials and ebooks about \ PHP, JavaScript, Java, Ruby, PL/SQL, MATLAB, C, Assembly, Swift, R, C++, Scratch, Visual Basic .NET, Go, Visual Basic, Delphi, C#, Python, Objective-C, Perl Julia, Fortran, Scala, LabVIEW, Bash, Alice, Logo, COBOL, Dart, Ada, Kotlin, Transact-SQL, F#, Scheme, SAS, ML, Clojure, Crystal, Rust, Lua, Prolog, D, FoxPro, Hack, ABAP, Erlang, VBScript, Lisp, Awk, Apex \ __

Sign In or Register to comment.