Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting numerical value from a string
#7
Solved: 10 Years, 9 Months, 2 Weeks ago
Hi Bavnah,

Please find the below code which will give a simple solution.In this LOC we did not consider ever "is".

Code:
str="this is my test string with 100% coverage."
Flag=False
NumChars=0
For i = 1 to len(str)
   ' msgbox mid (str,i,1)
    If isnumeric(mid(str,i,1))=True Then
        If Flag = False Then
            Flag=True
            StartPoint= i
            NumChars=NumChars+1
            Else
            NumChars=NumChars+1
        End if
    End If
Next
msgbox NumChars
If NumChars > 0 Then
    msgbox mid(str,StartPoint,NumChars)
    msgbox "My Desired value = " & mid(str,StartPoint,NumChars) & "%"
Else
    msgbox "No numeric chars are displayed in ''"& str &"''."
End If
Let me know if it's OK with you or do you want any other methods.

Thanks,
QTPKing.
Reply


Messages In This Thread
getting numerical value from a string - by bavnah - 07-08-2009, 01:51 AM
RE: getting numerical value from a string - by supputuri - 07-14-2009, 02:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace a string in a word document with another string rekha.naik 8 15,047 11-14-2013, 12:58 PM
Last Post: pranikgarg

Forum Jump:


Users browsing this thread: 2 Guest(s)