## User Tag List

Thanks:  0
Likes:  0
Dislikes:  0

hey guys when i add 2 numbers in vbscript i get the result as the concatenation of the two numbers. what should i do , pls don't give me the solution as

num1=1
num2=3
num3=num1+num2
msgbox num2

i know that this works but , i get the values for num1 and num2 dynamically ,
i am using this in a select case script ,
here is my script :

num1=inputbox("enter the first number ")
num2=inputbox("enter the second number ")
operation = InputBox("select one of the options from 1 , 2 , 3 , 4 for addition,subtraction,multiplication, division ")
Select Case operation
Case 1
Case 2
subt=num1-num2
MsgBox "The subtraction of two numbers is" &amp;subt
Case 3
mul=num1*num2
MsgBox "The multiplication of two numbers is" &amp;mul
Case 4
divi=num1/num2
MsgBox "The division of two numbers is" &amp;divi
case else
msgbox"select any option from 1 , 2 , 3 , 4 "
End Select

try addition operation and give me some ideas of how to overcome.This question may sound silly , but what to do i am a begineer [img]/images/graemlins/smile.gif[/img]

2. ## Re: add two numbers

This is because when you use InputBox it returns a string and the values are added as Strings.

Change

num1=inputbox("enter the first number ")
num2=inputbox("enter the second number ")

to

num1 = CInt(inputbox("enter the first number "))
num2 = Cint(inputbox("enter the second number "))

3. ## Re: add two numbers

Tarun ,
thanks a lot , the script works fine , can you just explain what that cint means and any other topics related to this subject ?

Thanks
MEYYAPPAN

4. ## Re: add two numbers

CInt - Convert to integer. You need go through a Basic course on VBScript

www.w3schools.com/VBScript

5. ## Re: add two numbers

thank you tarun !

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.