VB is new to me, dont laugh.
Part of the assignment is to make a simple calculator macro in Microsoft Excel. I've tested it and it seems to work pretty well, just wanted to post the code and see if anyone sees any major errors or improvements I can make.
Code:
Option Explicit
'Written by Jack Morrison
Sub mytoycalculator()
Dim Num1 As Integer
Dim Num2 As Integer
Dim Operator As String * 1
Dim Answer As Integer
Dim Success As Boolean
Num1 = InputBox("Enter the First Value")
Num2 = InputBox("Enter the Second Value")
Operator = InputBox("Enter the sign of the operation")
If Operator = "+" Then
Answer = (Num1 + Num2)
Success = True
ElseIf Operator = "-" Then
Answer = (Num1 - Num2)
Success = True
ElseIf Operator = "*" Then
Answer = (Num1 * Num2)
Success = True
ElseIf Operator = "^" Then
Answer = (Num1 ^ Num2)
Success = True
ElseIf Operator = "/" And (Num2 <> 0) Then
Answer = (Num1 / Num2)
Success = True
Else
Success = False
End If
If Success = True Then
MsgBox ("The Operation was successful, The Answer is " & Answer)
ElseIf Success = False Then
MsgBox ("The Operation Failed")
End If
End Sub
Thanks,
Axiom