Monday, November 3, 2014

VBScript Decision Making

Decision making is way to control the execution flow of a script or part of the script. A script can have none or one or more conditional statements.



'This program is to understand the Decision Making under VBScript.


dim a: a=int(inputbox("Enter Value for A"))  'By Default the input box will return String to convert into Int use Int funtion.

dim b: b= int(inputbox("Enter Value for B"))


if a>b then
msgbox "A("&a&") is greater Then B("&b&")."
elseif a=b then
msgbox "A("&A&") is equal to B("&B&")."
else
msgbox "B("&b&") is greater Then A("&a&")."
end if

dim opp: opp= inputbox("Enter Value operation + OR - OR * OR / or MOD")

'Switch statement

select case opp

case "+"
msgbox a&" + "&b&" = "& a+b

case "-"
msgbox a&" - "&b&" = "& a-b

case "*"
msgbox a&" * "&b&" = "& a*b

case "/"
msgbox a&" / "&b&" = "& a/b

case "MOD"
msgbox a&" MOD "&b&" ="& a MOD b


case else   ' Case Else is degfault Case, if none of the above case will exicute the Else case will get exicute.
msgbox " Invalid Operation"

end select