Micro Focus QTP (UFT) Forums
split a variable - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: split a variable (/Thread-split-a-variable)



split a variable - Brian - 04-15-2008

Hey guys,

I have a variable that is getting passed to me in the form of -
VarA = $2000.
My problem is when i start to try and use this variable as an Integer....such as when i try and add my variable to another integer -
VarA + 300 = VarB

Here i get a "type mismatch" error. (due to the $ sign in front of the 2000)

My question would be does anybody know how i can strip the $ sign away so that im left with just the Integer?

Thanks,
Brian


RE: split a variable - stech - 04-15-2008

convert that to an int using cint. for ex.
MyDouble = "$2000"
MyInt = CInt(MyDouble)
Msgbox (MyInt) will do the trick.


RE: split a variable - niranjan - 04-15-2008

Try using Split function.
Example:
Code:
Dim StrMsg, MyArray
StrMsg = "$2000"
MyArray = Split(StrMsg, "$", -1, 1)
' now
' MyArray(0) contains ""
' MyArray(1) will contain 2000

Msgbox MyArray(1)



RE: split a variable - mag - 04-17-2008

You can also use this,
d = "$1000"
msgbox Right(d, (Len(d)-1))