Roberto Terzaghi
Roberto Terzaghi

Reputation: 3

How to change two variables by YES/NO MessageBox in VBScript?

I need to change this by a YES/NO messagebox.

My script:

Dim i
Dim result
result = MsgBox("[YES] Windows10" & vbCrLf & vbCrLf & "[NO] WindowsXP", _
         vbYesNo Or vbQuestion, "Select your Windows OS:")
If result = vbYes Then
    i = "90"
Else
    i = "510"
End If

How do I change both variables for YES and NO?

Upvotes: 0

Views: 1112

Answers (1)

JNevill
JNevill

Reputation: 50119

I think you are close. You just need a couple more variables, besides i, since that is the one you are using in your for loop:

Dim i
Dim minI
Dim difference
Dim result

'prompt user for OS
result = MsgBox("[YES] Windows10" & VbCrLf & VbCrLf & "[NO] WindowsXP", _
    vbyesno or vbquestion, "Select your Windows OS:")

'change some variables depending on user answer
If result = vbyes Then
    minI=90
    difference = 189
Else
    minI=510
    difference = 870
End If

'Do your loop based on variables.
For i = minI to UBound(arrTemp) - difference

Next i

The only other thing is to not set you numeric variables with quotes around them.

Upvotes: 2

Related Questions