Results 1 to 3 of 3

Thread: Selecting combobox contents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    Cool Selecting combobox contents

    Hello,

    I have a newbie combobox question.

    The combobox contains California's cities but I don't want to hardcode something like:

    VB Code:
    1. If cboState.Text = "Sacramento" = Then
    2. 'Do something with the selection
    3. End If


    Is there any other property I can use in a selection without hardcoding?

    Any coding suggestions are welcomed!


    Chris
    Last edited by Trancedified; Mar 1st, 2004 at 06:05 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't know what you mean by hardcoding but this maybe another way .
    VB Code:
    1. Dim indx As Integer = Me.ComboBox1.SelectedIndex
    2.  
    3.         Select Case indx
    4.  
    5.             Case 0
    6.  
    7.             Case 1
    8.  
    9.             Case 2
    10.  
    11.         End Select

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Posts
    89

    Arrow

    Pirate,

    Sorry what I meant was for each city of California something is done differently maybe a few more checkboxes on the form being made available or something of that nature.

    For every city I don't want to hardcode because that piece of code will be too long, plus there are 50 states, making the code even longer.

    What I don't want to do is:

    VB Code:
    1. If cboState.SelectedItem = "Los Angeles" Then
    2.           CheckBox1.Visible = False
    3. End If

    Is there an alternative to keep the code smaller?


    Thanks

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width