Topic Options
#57704 - 09/25/20 01:09 PM VBScript Error
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 394
Loc: Home
Hi,
Below VB Script is giving me wrong result when I add two variables, can someone point out to me where am I doing wrong please.
I'm splitting data into batches and need the count for each file

Option explicit

Dim strCurrentCounter, strBatchCounter, strNewCounter
strCurrentCounter = Watch.GetVariable("Count")
strBatchCounter = Watch.GetVariable("BatchCount")
strNewCounter = strCurrentCounter + strBatchCounter
Watch.SetVariable "Count", strNewCounter

if I have Count = 6, BatchCount = 6 result should be 12 but it gives me 66, cause it's not recognizing it's numeric, it's taking is as text I guess, how can I fix this?


Edited by Sami786 (09/25/20 02:17 PM)
_________________________
Peace

Top
#57705 - 09/25/20 05:11 PM Re: VBScript Error [Re: Sami786]
drbrownz Offline
OL Newbie

Registered: 09/21/10
Posts: 5
Loc: Florida
hello - must convert to int, do math, then convert back to string:
strNewCounter = cstr(cint(strCurrentCounter) + cint(strBatchCounter))

hope this works for you.

Top
#57707 - 09/28/20 10:03 AM Re: VBScript Error [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 394
Loc: Home
of course, thank you!
_________________________
Peace

Top