i have a code which is in the if-then-else statement...
then i want to use the select case statement...
and i dont know well on this...
hope you can help me...
the code is

Private Sub cmdGo_Click()

Dim postA As Single
Dim postB As Single


If Combo1 = 1 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postB = 5550 To 11175 Step 0.1
Shape2.Left = postB
Next


ElseIf Combo1 = 2 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 4970 To 0 Step -0.1
Shape1.Left = postA
Next


ElseIf Combo1 = 3 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 4970 To 0 Step -0.1
Shape1.Left = postA
Next
For postB = 5550 To 11175 Step 0.1
Shape2.Left = postB
Next


ElseIf Combo1 = 4 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 4970 To 0 Step -0.1
Shape1.Left = postA
Next
For postB = 4970 To 0 Step -0.1
Shape2.Left = postB
Next


ElseIf Combo1 = 5 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 5550 To 11175 Step 0.1
Shape1.Left = postA
Next
For postB = 5550 To 11175 Step 0.1
Shape2.Left = postB
Next


ElseIf Combo1 = 6 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 5550 To 11175 Step 0.1
Shape1.Left = postA
Next
For postB = 5550 To 11175 Step 0.1
Shape2.Left = postB
Next


ElseIf Combo1 = 7 Then
For postA = 0 To 4970 Step 0.1
Shape1.Left = postA
Next
For postB = 11175 To 5550 Step -0.1
Shape2.Left = postB
Next
For postA = 5550 To 11175 Step 0.1
Shape1.Left = postA
Next
For postB = 5550 To 11175 Step 0.1
Shape2.Left = postB
Next


End If
End Sub

Im trying to make a program for our Physics which is collision and collision has 7 types. In every type there is an animation for two objects. That’s it!!!
Hope you can help me…
Thanks and have more powers to you all!!

Try this one:

Dim combotext as integer

combotext=val(Combo1.text)

Select case combotext

Case 1
....code here

Case 2
....code here

Case 3
....code here

Case 4
....code here

Case 5
....code here

Case 6
....code here

Case 7
....code here

End Select

thanks for the reply...
sorry for the disturbance...
i don't really know how to start the select case statement...
but i gonna used this code...
thank you very much...

Just like Ryan said just enter the code for each CASE.

In this case (yuk, yuk, yuk) I don't think your saving anything by using Select Case.

Here's the first 3 CASES in code, I'm sure you can handle it from there.

Private Sub cmdGo_Click()

Dim postA As Single
Dim postB As Single

    Select Case combotext
    Case 1
    
        For postA = 0 To 4970 Step 0.1
            Shape1.Left = postA
        Next
        For postB = 11175 To 5550 Step -0.1
            Shape2.Left = postB
        Next
        For postB = 5550 To 11175 Step 0.1
            Shape2.Left = postB
        Next
    
    Case 2
        For postA = 0 To 4970 Step 0.1
            Shape1.Left = postA
        Next
        For postB = 11175 To 5550 Step -0.1
            Shape2.Left = postB
        Next
        For postA = 4970 To 0 Step -0.1
            Shape1.Left = postA
        Next
    
    Case 3
        For postA = 0 To 4970 Step 0.1
            Shape1.Left = postA
        Next
        For postB = 11175 To 5550 Step -0.1
            Shape2.Left = postB
        Next
        For postA = 4970 To 0 Step -0.1
            Shape1.Left = postA
        Next
        For postB = 5550 To 11175 Step 0.1
            Shape2.Left = postB
        Next
        
        ' and so on and so forth until you get to 7
    
    
    End Select

End Sub

BTW...are you using the actual text in the ComboBox or are you using the item.index? You might be safer using the index.

Happy coding

This question has already been answered. Start a new discussion instead.