Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Absent Member.. vzamoraz Absent Member..
Absent Member..

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"
    End If



HP support



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.


Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.