VB Script - Simple Calculator

Steps to Run:
1] Open Notepad.exe or Notepad++.exe
2] Copy below VB script source code into notepad
3] Save File as "Calculate.vbs"
4] Run file and enter values



'Simple Calculator which take input of two values and pass operator sign (like +, -, *, /)

Dim val1,val2,optval,results
val1 = InputBox("Enter First Number Here: ","Title: Enter First Value") 
val2 = InputBox("Enter Second Number Here: ","Title: Enter Second Value") 
optval = InputBox("Enter Operator Value e.g. + , * , / , - : ","Title: Enter Operator Value") 


Select Case optval
Case "+"
results = CInt(val1) + CInt(val2)
Case "-"
results = CInt(val1) - CInt(val2)
Case "/"
results = CInt(val1) / CInt(val2)
Case "*"
results = CInt(val1) * CInt(val2)
End Select

MsgBox ("Your Results is : " & val1 & optval & val2 & " = " & results)



Short Summary(Learned so far):

1)  An Input box,
     An Input box is a way to respond to a question.  
It could be something like entering a values, password or choosing between multiple options, as in the case entered two number and operator values.

2)  A Message box,
     A Message box is a way to display a message and allow you to answer Yes, No, Cancel, Retry or Ignore.

3)  Select Case Statements,

     Select Case Statements tells the code what to do based upon the users input.

Note*: Please Enter few remarks below, if code is helpful for you.
Thanks.!

Comments

Popular posts from this blog

PUTTY - The server's host key is not cached in the registry cache

OIM-12c Installation - FMW - SOA - IDM

SAML & OAuth 2.0