7 QTP Casting Functions to Make You a QTP Automation Wizard

If you’re striving to become the next Harry Potter or Gandalf the Gray of QTP, then learn this lesson well. Your quest, if you choose to accept it, is to seek out the scroll of casting. Do so and unlock the key to QTP’s casting conversion functions.
- CInt()
To transform strings into integers, you first need to use Cint() to cast the string to its integer value. If you don’t, the enchanted VBScript engine interprets the values as strings, not numbers! For example:
‘Bad script example:
‘Good script example:
- CBool
To return a Boolean value of an expression for true/false conditions — Hocus-pocus, Allakhazam!:
- CLong
If a value needs to be between -2147483648 and 2147483647, and a value of, say, 6,579.56 is used, you can change it by using CLNG:
msgbox CLng("6,579.56")
will return a value of 6580
- Asc
msgbox Asc("J") returns a value of 74, which is the ANSI code for “J”
- Cbyte
msgbox Cbyte("7.77") returns a value of 8 because the value is rounded up
- ChrB
msgbox ChrB(74) returns a value of J, which is the number 74 in the ANSI table
- HEX
And finally, to use QTP to put a “Hex” on a bug (…get it?) use the HEX function:
msgbox Hex(16777215) — this will return the Hex value of FFFFFF which, by the way, is the hexadecimal number for the color black.
If you got a chuckle out of this blog, and enjoy reading, you might like the book Wizard’s Bane by Rick Cook — a comical fantasy about a programmer who invents a computer language for casting magic spells. A free online version of the book can be found here
Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.
Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.
With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.
He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.
Follow him on LinkedIn or check out more at TestGuild.com.
Related Posts
Look, I’ve been doing test automation for over 25 years. I’ve heard the predictions. “Manual testing is dead.” “AI will […]
The 72.8% Paradox That Changes Everything After interviewing 50+ testing experts in 2025 and analyzing data from our 40,000+ member […]
Look, I’ve been doing this testing thing for over 25 years now. I first wrote about the AI “three waves” […]
What’s New in Low-Code/No-Code Testing for 2026 A lot had changed on the The low-code/no-code testing space and it has […]



