iflarexd
iflarexd

Reputation: 23

Vbs Addition Sequence Isn't Working?

I am currently trying to made a calculator with Addition, Subtraction, Multiplication, and Division with vbs. It all works except addition. When I do addition it sticks the numbers beside each other. So if I entered 2+2 it would equal 22. Here's the script!

Dim A
Dim B
Dim C
A=inputbox("Enter Your First Number")
B=inputbox("Enter Your Second Number")
C=A + B
MsgBox("Your answer is:" & C)

If anyone knows how to fix this I'd really appreciate it!

-Flare

Upvotes: 1

Views: 133

Answers (1)

Stack
Stack

Reputation: 348

Convert A and B to integers:

Dim A
Dim B
Dim C
A = inputbox("Enter Your First Number")
B = inputbox("Enter Your Second Number")
C = CInt(A) + CInt(B)
MsgBox("Your answer is: " & C)

Upvotes: 1

Related Questions