Monday, 23 September 2013

What are different conditional statements in vbscript?

In Vbscript there are 2 types of conditional statements.

  1. if ...else
  2. Select Case
Example of if else - 

a = 10

If a > 10 Then
  Msgbox "a is greater than 10"
ElseIf a>0 then
  Msgbox "a is between 0 and 11"
  Msgbox "a is not greater than 0"
End If

Example of select case - 

a = Inputbox("enter the number")

Select Case cint(a)

  Case 1  

     msgbox "You entered 1"

  Case 2
     msgbox "You entered 2"

  Case 3
     msgbox "You entered 3"

  Case else
     msgbox "You entered invalid input"

End Select

No comments:

Post a Comment

Total Pageviews