Results 1 to 4 of 4

Thread: Addition operation in VB Script.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Posts
    17

    Addition operation in VB Script.

    Hi,
    I have to perform an addition operation of these variables. The variables look like this:
    var1 = TRIM(CSTR(objRs.Fields
    ("var1").Value)) the value is 6

    var2 = TRIM(CSTR(objRs.Fields
    ("var2").Value)) the value is 1
    I want the result to be 6+1 as 7
    but when I try to compute this I used
    total = var1 + var2 and my total shows as 16 which is the string concatenation. How do I change this string to be an integer?
    ANy pointers will be great.
    Thanks
    Sri

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Addition operation in VB Script.

    var1 = cint(TRIM(CSTR(objRs.Fields
    ("var1").Value)))

    var2 = cint(TRIM(CSTR(objRs.Fields
    ("var2").Value)))


    Use the cint() function, then try the addition.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Posts
    17

    Thumbs up Thanks!

    Thanks for your help. Cint() did the trick!

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Thumbs up

    YW

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width