Stuart McLachlan
stuart at lexacorp.com.pg
Tue Apr 12 07:22:17 CDT 2005
On 12 Apr 2005 at 22:18, Stuart McLachlan wrote:
>
> This version handles "+2" and "-2" etc in the string as well:
>
Yet another mod. I missed and then didn't test for a "0" in the test
string. This one should do it properly:
Function Addnumbers(InputString As String) As Double
Dim lngStore As Double
Dim lngLoopcount As Double
lngLoopcount = 0
Do
lngLoopcount = lngLoopcount + 1
lngStore = lngStore + Val(Mid$(InputString, lngLoopcount))
'move past current number
While InStr("0123456789+-", Mid$(InputString, lngLoopcount, 1)) > 0
lngLoopcount = lngLoopcount + 1
Wend
Loop Until lngLoopcount >= Len(InputString)
Addnumbers = lngStore
End Function
--
Stuart