add two numbers in a script vbs file

Robert Eisenbach 0 Reputation points
2023-03-25T19:04:58.9933333+00:00

The statement Result = number1 + number2 returns the joining of the numbers and not the sun.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,438 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 13,735 Reputation points
    2023-03-25T19:26:55.4133333+00:00

    Convert the values to integer

    Result = CInt(number1) + CInt(number2)
    
    

    In VBScript, the + operator can be used for both addition and concatenation.

    If number1 and number2 are variables containing numeric values,

    then the statement Result = number1 + number2 will correctly return the sum of the two numbers.

    0 comments No comments

Your answer

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