airthmatic operator in vbscript

Go4Expert Member
19Jun2007,09:26   #1
manojkumarmaithil's Avatar
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
Go4Expert Founder
19Jun2007,10:51   #2
shabbir's Avatar
You define a,b and c as integers specifically.
Go4Expert Member
23Jun2007,07:39   #3
manojkumarmaithil's Avatar
could you please send me the code sinnept because i tried your idea but it doesn't work
Team Leader
23Jun2007,10:06   #4
pradeep's Avatar
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)
Go4Expert Member
24Jun2007,13:04   #5
manojkumarmaithil's Avatar
thanks for your response .
Go4Expert Member
7Jul2007,14:28   #6
shadowskill404's Avatar
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"

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