VBScript Error

Posted by: Sami786

VBScript Error - 09/25/20 01:09 PM

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?
Posted by: drbrownz

Re: VBScript Error - 09/25/20 05:11 PM

hello - must convert to int, do math, then convert back to string:
strNewCounter = cstr(cint(strCurrentCounter) + cint(strBatchCounter))

hope this works for you.
Posted by: Sami786

Re: VBScript Error - 09/28/20 10:03 AM

of course, thank you!