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 for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 14,280 Reputation points MVP Volunteer Moderator
    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.