Joe Strazzere - All Things Quality

Visit my new blog at http://strazzere.blogspot.com/


November 13, 2009 - WinTask - ToNumber()

Posted in WinTask

 

 

'
' 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"))



Any comments on this article?
Email Me


<- Last Page :: Next Page ->

About Me

A gathering place for information and ideas about Quality Assurance, Testing, and other useful topics.

Problems cannot be solved by the same level of thinking that created them. - A. Einstein

Search This Site

Translate This Site

RSS Feed

Subscribe

Twitter

@jstrazzere

Categories

Life
QA
Sports
Tools
WinTask
Work in General

What I'm Reading Now