Share via

VBScript addition

Brod Blox 1 Reputation point
2021-11-29T06:57:23.827+00:00

My code looks like this:

int a = InputBox("Enter Amount 1", "Calculator", "Number")
int b = InputBox("Enter Amount 2", "Calculator", "Number")
Mode = InputBox("Enter Mode. 1 is Add, 2 is Subtract, 3 is Multiply, and 4 is Divide.", "", "1, 2, 3, 4")
Select Case Mode
Case 1
c = a+b
Case 2
c = a-b
Case 3
c = a*b
Case 4
c = a/b
End Select

x = MsgBox("The answer is: " & c, 0, "Calculator")

But when ever I add the 2 a and b variables as both of them being 5, I get 55. This should only happen when I use the ampersand symbol, right? Is there any way to fix this issue? I am using Notepad from Microsoft. I could not find a suitable tag so I just added random ones since there is no way for me to not have tags on a post.

Microsoft 365 and Office | Development | Other
Windows for business | Windows Client for IT Pros | Devices and deployment | Other
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.