Results 1 to 5 of 5

Thread: Combo Combo [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Combo Combo [RESOLVED]

    For some reason I can't work this out. I have two combo boxes. The first Combo1 lists all options (there are 10 options). The second Combo2 lists the "end option". The program will process all records from Combo1 to Combo2. It's a basic sort of "For x= Combo1 to Combo2" type deal. So Combo2 must always be equal or greater than or equal to Combo1, and the Combo2 list only includes values greater than or equal to Combo1 selection.

    So: If User selects Combo1 value greater than Combo2 value, then Combo2 value is same as Combo1. If User selects Combo1 less than than Combo2 value, then Combo2 value stays the same, but the Combo2 list expands to include all option of Combo1 or greater and adjusts the Combo2 selection. Do you follow? Combo2 is a list of all Combo1 selection and higher. Combo2 selection stays the same unless Combo1 selection is higher.

    Here's what I have:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim lStage
    4. Dim lStageEnd
    5.  
    6. Private Sub Form_Load()
    7.  
    8.     ' Example start value.
    9.     lStage = 7
    10.  
    11.     With Combo1
    12.         .AddItem "0"
    13.         .AddItem "1"
    14.         .AddItem "2"
    15.         .AddItem "3"
    16.         .AddItem "4"
    17.         .AddItem "5"
    18.         .AddItem "6"
    19.         .AddItem "7"
    20.         .AddItem "8"
    21.         .AddItem "9"
    22.     End With
    23.     Combo1.ListIndex = lStage
    24.     Label1.Caption = lStage
    25.    
    26.     Combo2.Clear
    27.     With Combo2
    28.         If lStage <= 0 Then .AddItem "0"
    29.         If lStage <= 1 Then .AddItem "1"
    30.         If lStage <= 2 Then .AddItem "2"
    31.         If lStage <= 3 Then .AddItem "3"
    32.         If lStage <= 4 Then .AddItem "4"
    33.         If lStage <= 5 Then .AddItem "5"
    34.         If lStage <= 6 Then .AddItem "6"
    35.         If lStage <= 7 Then .AddItem "7"
    36.         If lStage <= 8 Then .AddItem "8"
    37.         If lStage <= 9 Then .AddItem "9"
    38.     End With
    39.  
    40.     lStageEnd = Combo2.ListCount - 1
    41.     Combo2.ListIndex = lStageEnd
    42.     Label2.Caption = lStageEnd
    43.  
    44. End Sub
    45.  
    46. Private Sub Combo1_Click()
    47.  
    48.     Dim lStageOld As Integer
    49.    
    50.     lStageOld = lStage
    51.    
    52.     lStage = Combo1.ListIndex
    53.     Label1.Caption = lStage
    54.    
    55.     Combo2.Clear
    56.     With Combo2
    57.         If lStage <= 0 Then .AddItem "0"
    58.         If lStage <= 1 Then .AddItem "1"
    59.         If lStage <= 2 Then .AddItem "2"
    60.         If lStage <= 3 Then .AddItem "3"
    61.         If lStage <= 4 Then .AddItem "4"
    62.         If lStage <= 5 Then .AddItem "5"
    63.         If lStage <= 6 Then .AddItem "6"
    64.         If lStage <= 7 Then .AddItem "7"
    65.         If lStage <= 8 Then .AddItem "8"
    66.         If lStage <= 9 Then .AddItem "9"
    67.     End With
    68.    
    69.     If lStageEnd <= lStage Then
    70.         Combo2.ListIndex = 0
    71.     Else
    72.         Combo2.ListIndex = lStageEnd + (lStage - lStageOld)
    73.     End If
    74.  
    75. End Sub
    76.  
    77. Private Sub Combo2_Click()
    78.     lStageEnd = Combo1.ListIndex + Combo2.ListIndex
    79.     Label2.Caption = lStageEnd
    80. End Sub
    Last edited by WorkHorse; May 20th, 2003 at 08:39 PM.

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