QTP/UFT support tip: How validate a string for special characters
There are cases where the application under test has a fields that does not allow special characters.
In that cases you can implement vbscript code to validate the precense of special characters in the parameter and take decisions about it.
In the example below the user enter a name and the code validate if it has special character:
myvarname = inputbox("Type the name") 'Loop for the amoun of characters in the string For index = 1 To len(myvarname) 'Take a character from the string in order from left to right mycharacter = ucase(mid(myvarname, index,1)) 'Made the character capital letter mycharacter = asc(mycharacter) 'Search the ASCII code with Capital letters and numbers If (mycharacter < 65 or mycharacter>90) and (mycharacter < 48 or mycharacter>57) Then msgbox "The name has special character" index=len(myvarname) End If Next
Note: The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.