Your gathering place for information and ideas about Quality Assurance, Testing, and other topics of interest.
November 13, 2009
WinTask - ToNumber()
'
' ToNumber()
'
' Author: Joe Strazzere
'
' Removes all non-numerics from a string and returns a number
'
Function ToNumber(test$)
Local i
Local new$
Local work$
work$=""
i=1
While i<= len(test$)
Select Case Mid$(test$,i,1)
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
new$=Mid$(test$,i,1)
Case Else
new$=""
EndSelect
work$=work$+new$
i=i+1
Wend
ToNumber=Val(work$)
EndFunction
MsgBox(ToNumber("$123,456.78"))
Labels:
WinTask