airthmatic operator in vbscript

manojkumarmaithil's Avatar, Join Date: Jun 2007
Go4Expert Member
when i use + operator in vbscript it not add two variable it works like string formate
i.e dim a , b,c
a=40,b=30
c=a+b
result=4030
while desire result should be 70
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You define a,b and c as integers specifically.
manojkumarmaithil's Avatar, Join Date: Jun 2007
Go4Expert Member
could you please send me the code sinnept because i tried your idea but it doesn't work
pradeep's Avatar, Join Date: Apr 2005
Team Leader
I guess it's JavaScript and not VBScript, in VBScript the concatenation operator is &
If it's JavaScript, here's the solution!
Code: JavaScript
var a=40
var b=30;
c=parseInt(a)+parseInt(b);

And similar code for VBScript
Code: VBScript
Dim a=40,b=30
c=CInt(a)+CInt(b)
manojkumarmaithil's Avatar, Join Date: Jun 2007
Go4Expert Member
thanks for your response .
shadowskill404's Avatar, Join Date: Jul 2007
Go4Expert Member
HTML Code:
dim a , b,c
a=40,b=30
c=a+b
result=4030
while desire result should be 70
thats weird....manojkumarmaithil

... because The Host should interpret your variables to be variant... it means that base from your code the result should be 70...

But it seems to me that theres just something wrong in your code...

please refer to line number 2 of your code... You cant do a comma when assigning values... try this one instead...
------------------
dim a , b,c
a=40
b=30
c=a+b
msgbox c, "Result is"

--------------------