Stuart McLachlan
stuart at lexacorp.com.pg
Tue Apr 12 07:03:13 CDT 2005
On 12 Apr 2005 at 7:43, Bobby Heid wrote: > But if any of the numbers is greater than 9, this will not work properly. > It does look like it works ok for numbers less than 10. > It doesn't work. I should have put lngStore = lngStore + Val(Mid$(InputString,lngLoopcount,1)) instead of lngStore = Val(Mid$(InputString,lngLoopcount,1)) That said, this one does work with multi digit numbers: Function Addnumbers(InputString As String) As Long Dim lngStore As Long Dim lngLoopcount As Long lngLoopcount = 0 Do lngLoopcount = lngLoopcount + 1 lngStore = lngStore + Val(Mid$(InputString, lngLoopcount)) 'move past current number While IsNumeric(Mid$(InputString, lngLoopcount, 1)) lngLoopcount = lngLoopcount + 1 Wend Loop Until lngLoopcount >= Len(InputString) Addnumbers = lngStore End Function -- Stuart