My first Calculator ( Still in progress)

Author Message
4CAMan

  • Total Posts : 11
  • Scores: 0
  • Reward points : 0
  • Joined: 1/9/2011
  • Location: VA, United States of America
  • Status: offline
My first Calculator ( Still in progress) Monday, January 10, 2011 3:09 PM (permalink)
0
I plan on adding a main menu because I know it is annoying to have to go through each system of equations.
 
the calculator does the following things, in this order.  ( if you want to get to one, you have to go through the other; i understand this is a problem)
  • Multiplication
  • Addition
  • Division
  • Subtraction
  • Absolute Value
  • Raising to a power (up to the tenth power; powers 0 through 10)
 
If you submit something that is not numerical, it will register as a value of zero. If you hit cancel, it will continue to the next input box.  I also plan on making it so that when you hit cancel, it closes the vbscript.  Hope you enjoy!
=================================================================
Dim a, b, sum
a=inputbox("Input your first number to be multiplied.", "Multiplication- First Number", "Enter your number")
b=inputbox("Input your second number to be multiplied.", "Multiplication-Second Number", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
if not isnumeric (b) then
b = false
end if
If b = vbCancel then
wscript.quit
end if
c=msgbox("Your Answer: "& a * b, vbInformation, "Product")
a=inputbox("Input your first value to be added.", "Addition- First Value", "Enter your number")
b=inputbox("Input your second value to be added.", "Addition- Second Value", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
if not isnumeric (b) then
b = false
end if
If b = vbCancel then
wscript.quit
end if
sum= Cdbl (a) + Cdbl(b)
MsgBox "Your Answer: " & sum, vbInformation, "Sum"
a=inputbox("Input your first number to be divided.", "Division- First Number", "Enter your number")
b=inputbox("Input your second number to be divided.", "Division-Second Number", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
if not isnumeric (b) then
b = false
end if
If b = vbCancel then
wscript.quit
end if
c=msgbox("Your Answer: "& a / b, vbInformation, "Quotient")
a=inputbox("Input your first value to be Subtracted.", "Subtraction- First Value", "Enter your number")
b=inputbox("Input your second value to be Subtracted.", "Subtraction- Second Value", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
if not isnumeric (b) then
b = false
end if
If b = vbCancel then
wscript.quit
end if
difference= Cdbl (a) - Cdbl(b)
MsgBox "Your Answer: " & difference, vbInformation, "Difference"
a=inputbox("Input the the value you want the absolute value of.", "Absolute Value- Input Value", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
msgbox  "Your Answer: " & abs(a), vbInformation, "Absolute Value"
a=inputbox("Input the the value you want raised to a power.", "Base Number- Input Value", "Enter your number")
if not isnumeric (a) then
a = false
end if
If a = vbCancel then
wscript.quit
end if
b=inputbox("Input your the desired exponent as the second value (any value from 0 to 10).", "Exponent- Second Value", "Enter your number")
if not isnumeric (b) then
b = false
end if
If b = vbCancel then
wscript.quit
end if
if b = 0 then
msgbox "Your Answer: " & 1, vbInformation, "Number Raised to an Exponent"
end if
if b = 1 then
msgbox  "Your Answer: " & a, vbInformation, "Number Raised to an Exponent"
end if
if b = 2 then
msgbox  "Your Answer: " & a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 3 then
msgbox  "Your Answer: " & a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 4 then
msgbox  "Your Answer: " & a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 5 then
msgbox  "Your Answer: " & a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 6 then
msgbox  "Your Answer: " & a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 7 then
msgbox  "Your Answer: " & a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 8 then
msgbox  "Your Answer: " & a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 9 then
msgbox  "Your Answer: " & a * a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
if b = 10 then
msgbox  "Your Answer: " & a * a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
end if
 
 
#1
    4CAMan

    • Total Posts : 11
    • Scores: 0
    • Reward points : 0
    • Joined: 1/9/2011
    • Location: VA, United States of America
    • Status: offline
    Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 6:54 AM (permalink)
    0
    correction: the last three lines, if b = 10 then... should have one more a in it.
     
    #2
      ebgreen

      • Total Posts : 8227
      • Scores: 98
      • Reward points : 0
      • Joined: 7/12/2005
      • Status: offline
      Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 7:00 AM (permalink)
      0
      I would highly suggest researching the use of an HTA to vastly improve your interface.
      "... 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
       
      #3
        4CAMan

        • Total Posts : 11
        • Scores: 0
        • Reward points : 0
        • Joined: 1/9/2011
        • Location: VA, United States of America
        • Status: offline
        Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 10:00 AM (permalink)
        0
        he is the new calculator with the power of 10 lines corrected and a main menu:
        =============================================
        Set wshshell=wscript.createobject("wscript.shell")
        Dim msg,input
        msg = "Choose System of Equations:" & vbCR
        msg = msg & "" & vbCR
        msg = msg & "1. Multiplication " & vbCR
        msg = msg & "2. Addition " & vbCR
        msg = msg & "3. Division " & vbCR
        msg = msg & "4. Subtraction " & vbCR
        msg = msg & "5. Absolute Value " & vbCR
        msg = msg & "6. Raising to a Power" & vbCR
        input = InputBox(msg,"Calculator Main Menu")
        Select Case input
         
        case "1"
        Dim a, b, sum
        a=inputbox("Input your first number to be multiplied.", "Multiplication- First Number", "Enter your number")
        b=inputbox("Input your second number to be multiplied.", "Multiplication-Second Number", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        if not isnumeric (b) then
        b = false
        end if
        If b = vbCancel then
        wscript.quit
        end if
        c=msgbox("Your Answer: "& a * b, vbInformation, "Product")
         
        case "2"
        a=inputbox("Input your first value to be added.", "Addition- First Value", "Enter your number")
        b=inputbox("Input your second value to be added.", "Addition- Second Value", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        if not isnumeric (b) then
        b = false
        end if
        If b = vbCancel then
        wscript.quit
        end if
        sum= Cdbl (a) + Cdbl(b)
        MsgBox "Your Answer: " & sum, vbInformation, "Sum"
         
        case "3"
        a=inputbox("Input your first number to be divided.", "Division- First Number", "Enter your number")
        b=inputbox("Input your second number to be divided.", "Division-Second Number", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        if not isnumeric (b) then
        b = false
        end if
        If b = vbCancel then
        wscript.quit
        end if
        c=msgbox("Your Answer: "& a / b, vbInformation, "Quotient")
         
        case "4"
        a=inputbox("Input your first value to be Subtracted.", "Subtraction- First Value", "Enter your number")
        b=inputbox("Input your second value to be Subtracted.", "Subtraction- Second Value", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        if not isnumeric (b) then
        b = false
        end if
        If b = vbCancel then
        wscript.quit
        end if
        difference= Cdbl (a) - Cdbl(b)
        MsgBox "Your Answer: " & difference, vbInformation, "Difference"
         
        case "5"
        a=inputbox("Input the the value you want the absolute value of.", "Absolute Value- Input Value", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        msgbox  "Your Answer: " & abs(a), vbInformation, "Absolute Value"
         
        case "6"
        a=inputbox("Input the the value you want raised to a power.", "Base Number- Input Value", "Enter your number")
        if not isnumeric (a) then
        a = false
        end if
        If a = vbCancel then
        wscript.quit
        end if
        b=inputbox("Input your the desired exponent as the second value (any value from 0 to 10).", "Exponent- Second Value", "Enter your number")
        if not isnumeric (b) then
        b = false
        end if
        If b = vbCancel then
        wscript.quit
        end if
        if b = 0 then
        msgbox "Your Answer: " & 1, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 1 then
        msgbox  "Your Answer: " & a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 2 then
        msgbox  "Your Answer: " & a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 3 then
        msgbox "Your Answer: " & a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 4 then
        msgbox  "Your Answer: " & a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 5 then
        msgbox  "Your Answer: " & a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 6 then
        msgbox  "Your Answer: " & a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 7 then
        msgbox  "Your Answer: " & a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 8 then
        msgbox  "Your Answer: " & a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 9 then
        msgbox  "Your Answer: " & a * a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        if b = 10 then
        msgbox  "Your Answer: " & a * a * a * a * a * a * a * a * a * a, vbInformation, "Number Raised to an Exponent"
        end if
        End Select
         
        #4
          ebgreen

          • Total Posts : 8227
          • Scores: 98
          • Reward points : 0
          • Joined: 7/12/2005
          • Status: offline
          Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 10:38 AM (permalink)
          0
          What if I want to raise it to the 11th power?
           
          "... 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
           
          #5
            4CAMan

            • Total Posts : 11
            • Scores: 0
            • Reward points : 0
            • Joined: 1/9/2011
            • Location: VA, United States of America
            • Status: offline
            Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 11:18 AM (permalink)
            0
            lol.  I could always extend the script to make it go higher.
             
            #6
              ebgreen

              • Total Posts : 8227
              • Scores: 98
              • Reward points : 0
              • Joined: 7/12/2005
              • Status: offline
              Re:My first Calculator ( Still in progress) Tuesday, January 11, 2011 11:43 AM (permalink)
              0
              There is a better way. Research the exponent operator.
              "... 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
               
              #7

                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