Sponsored Ad

Tuesday, November 9, 2010

QTP Script: How to Count Alpha Characters in a String

This QTP Script will help you to count total alpha chars in a given string. Please note that isnumeric function is used to check the numeric values.

QTP Script to count Alpha Chars:

Dim myStr 
Dim AlphaCharCount
myStr="Step by Step QTP Learning 123." 

AlphaCharCount=0 
For i=1 to len(myStr)
    If not isnumeric (mid(myStr,i,1)) then 
        AlphaCharCount=AlphaCharCount+1  
    End if       
Next 
msgbox AlphaCharCount

Output of Given Program:

QTP Script: How to Count Alpha Characters in a String

2 comments:

  1. Shouldn't the answer be "26"? The period "." is not an alpha character.

    There's a total of 30 chars: 26 alphas, 3 numerics, and one special.

    ReplyDelete
  2. Yes, you are right. this code is for non numeric char. which includes the spacial chara also.

    ReplyDelete

Sponsored Ad

Development Updates

Tech Updates