Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   airthmatic operator in vbscript (http://www.go4expert.com/forums/airthmatic-operator-vbscript-t4753/)

manojkumarmaithil 19Jun2007 09:26

airthmatic operator in vbscript
 
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 :o

shabbir 19Jun2007 10:51

Re: airthmatic operator in vbscript
 
You define a,b and c as integers specifically.

manojkumarmaithil 23Jun2007 07:39

Re: airthmatic operator in vbscript
 
could you please send me the code sinnept because i tried your idea but it doesn't work

pradeep 23Jun2007 10:06

Re: airthmatic operator in vbscript
 
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 24Jun2007 13:04

Re: airthmatic operator in vbscript
 
thanks for your response . :)

shadowskill404 7Jul2007 14:28

Re: airthmatic operator in vbscript
 
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"

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


All times are GMT +5.5. The time now is 05:39.