VideoHelp Forum




+ Reply to Thread
Results 1 to 4 of 4
  1. Member
    Join Date
    Jul 2002
    Location
    Up in yo' bitch.
    Search Comp PM
    I have a combo with several items. With the selection of each individual item, a different action would be performed. Is there a way to code this simply rather than using 19 separate IF/THEN statements?

    Currently it would look something like this:

    If cboComboBox.Text = X Then
    A=B

    This is just an example. But imagine that about 20 times. It gets a little long.
    Quote Quote  
  2. Always Watching guns1inger's Avatar
    Join Date
    Apr 2004
    Location
    Miskatonic U
    Search Comp PM
    I haven't coded in VB in a long time (probably since VB3) and have only recently dabbled with C#, so maybe this wont help, but what about a case type statement. Not a lot less work, but probably easier in the long run. Don't know the exact syntax though.
    Read my blog here.
    Quote Quote  
  3. VH Veteran jimmalenko's Avatar
    Join Date
    Aug 2003
    Location
    Down under
    Search PM
    Case syntax would be something like the following (in the cboComboBox_Change() sub) :
    Code:
    Select Case cboComboBox.Text
    Case "X"
    A=B
    Case "Y"
    C=D
    Case Else
    E=F
    End Select
    ... or alternatively run it off the Index property (which IIRC is available in the _change() event).

    ... or alternatively you *might* be able to use an array.
    If in doubt, Google it.
    Quote Quote  
  4. Always Watching guns1inger's Avatar
    Join Date
    Apr 2004
    Location
    Miskatonic U
    Search Comp PM
    I had some very heavy 3d rendering sucking the life out of machine last night, so I couldn't look up the syntax - thanks for filling in the gaps.
    Read my blog here.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!