My Calculator

Author Message
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)
0


'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
 
#1
    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)
    0
    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
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      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)
      0
      Awesome thanks for the advice!  will break into the habit.


       
      #3
        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)
        0
        My calculator

        Switch to constantly open Powershell window
        Type the sum

        God, I love Powershell
        Author of ManagePC - http://managepc.net

         
        #4
          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)
          0
          It works, Check out mine.
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9