MrDinoC
-
Total Posts
:
15
- Scores: 0
-
Reward points
:
0
- Joined: 9/17/2010
-
Status: offline
|
My Calculator
Wednesday, September 22, 2010 10:03 PM
( permalink)
'First number input Dim Num1 '2nd number input Dim Num2 'Answer to Num1 Num2 Dim Answer 'continue with another calculation Dim Continue 'choose what sign to calculate on Dim Operator 'loop until user input is n Do until Continue="n" Operator= inputbox("A,S,D,M") Num1= Cint(InputBox("Please enter the first number:")) Num2= Cint(InputBox ("Please enter the second number:")) If Operator="a" then Answer=Num1+Num2 elseif Operator="s" then Answer=Num1-Num2 elseif Operator="d" then Answer=Num1/Num2 elseif Operator="m" then Answer=Num1*Num2 End if Wscript.Echo Answer Continue=inputbox ("Do another calculation y/n?") loop
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:My Calculator
Thursday, September 23, 2010 12:08 AM
( permalink)
Thanks for sharing. Here are some comments: 1) Option Explicit - Get in the habit of using it. Always. 2) Variable Names - Your variable names are meaningful which is good. Putting the type info in the variable name (i.e. strContinue) would be even better. 3) White Space - It may hgave been a fluke of posting to the forum, but using proper indentation will make your code much easier to read. 4) If-then-else - Generally speaking if you are going beyond two blocks in an if-then construct, you should probably consider using a Select-Case construct instead
|
|
|
|
MrDinoC
-
Total Posts
:
15
- Scores: 0
-
Reward points
:
0
- Joined: 9/17/2010
-
Status: offline
|
Re:My Calculator
Thursday, September 23, 2010 12:28 AM
( permalink)
Awesome thanks for the advice!  will break into the habit.
|
|
|
|
ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
Re:My Calculator
Friday, September 24, 2010 12:56 AM
( permalink)
My calculator Switch to constantly open Powershell window Type the sum God, I love Powershell
|
|
|
|
CØLLØSUS
-
Total Posts
:
21
- Scores: 2
-
Reward points
:
0
- Joined: 1/3/2011
-
Status: offline
|
Re:My Calculator
Thursday, January 06, 2011 10:14 PM
( permalink)
It works, Check out mine.
|
|
|
|