Your gathering place for information and ideas about Quality Assurance, Testing, and other topics of interest.
November 13, 2009
WinTask - ToDollar()
'
' ToDollar()
'
' Author: Joe Strazzere
'
' Removes all non-numerics from a string and returns a number,
' stopping at the first decimal point.
'
Function ToDollar(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 "."
new$=""
i=len(test$)
Case Else
new$=""
EndSelect
work$=work$+new$
i=i+1
Wend
ToDollar=Val(work$)
EndFunction
MsgBox(ToDollar("$123,456.78"))
Labels:
WinTask