Case select in vbscript not working properly

I have vbcode that works. I have to use the same code twice with a little changes. I put them under 2 cases  which I did using the method below. Even though I choose case 1, it executes the steps in case 2 as well. I am using wscript.quit at the end of the script.
Any ideas how can I avoid that?

Dim response
response = InputBox("Please enter 1, 2 or 3", , "Input Required")
Select Case response
    Case 1
        'do stuff back up file to D partition, etc.

    Case 2
        'do stuff to zip folder/files

    Case 3
        'do stuff appropriate for when 3 is entered

    Case Else
        'this is the fall-back for when the user enters someting other than 1, 2 or 3
        MsgBox "You didn't enter a 1, 2 or 3!", , "Invalid Entry"

End Select


Thanks,
Vicki
Vicki05Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Put an Exit Sub after the code in each Case?
0
Bill PrewCommented:
Works fine for me, I created the following in a small VBS file and it worked as expected, only displaying the msg of each case.

Is this part of some larger script, since the code you posted works properly.

Dim response
response = InputBox("Please enter 1, 2 or 3", , "Input Required")
Select Case response
    Case 1
        msgbox "case 1"

    Case 2
        msgbox "case 2"

    Case 3
        msgbox "case 3"

    Case Else
        'this is the fall-back for when the user enters someting other than 1, 2 or 3
        MsgBox "You didn't enter a 1, 2 or 3!", , "Invalid Entry"

End Select

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vicki05Author Commented:
I have a script that installs files to the computer. I wanted to use that and put it in the script shown above. When I used it even though it went to the correct message box, it jumped and executed from case 2.

Case 1 and Case 2 have the same script except for couple of files to be copied.
0
Bill PrewCommented:
So are you saying you saw multiple message boxes when you ran the test I posted?

If so, how exactly are you executing the script?

Also, did you change any lines of the code, or use it exactly as shown, and not add or change anything?

~bp
0
Vicki05Author Commented:
Thanks for the help. I approached it differently. The used case 2 for patching the system. It worked that way.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.