airthmatic operator in vbscript

Discussion in 'JavaScript and AJAX' started by manojkumarmaithil, Jun 19, 2007.

  1. manojkumarmaithil

    manojkumarmaithil New Member

    Joined:
    Jun 18, 2007
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    0
    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 :eek:
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You define a,b and c as integers specifically.
     
  3. manojkumarmaithil

    manojkumarmaithil New Member

    Joined:
    Jun 18, 2007
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    0
    could you please send me the code sinnept because i tried your idea but it doesn't work
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    I guess it's JavaScript and not VBScript, in VBScript the concatenation operator is &
    If it's JavaScript, here's the solution!
    Code:
    var a=40
    var b=30;
    c=parseInt(a)+parseInt(b);
    
    And similar code for VBScript
    Code:
    Dim a=40,b=30
    c=CInt(a)+CInt(b)
    
     
  5. manojkumarmaithil

    manojkumarmaithil New Member

    Joined:
    Jun 18, 2007
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    0
    thanks for your response . :)
     
  6. shadowskill404

    shadowskill404 New Member

    Joined:
    Jul 7, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    HTML:
    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"

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

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice