Pedro Janssen
pedro at plex.nl
Wed Apr 13 13:42:58 CDT 2005
Hello Stuart, that did the trick. Thanks for the help. Pedro Janssen ----- Original Message ----- From: "Stuart McLachlan" <stuart at lexacorp.com.pg> To: "Access Developers discussion and problemsolving" <accessd at databaseadvisors.com> Sent: Tuesday, April 12, 2005 11:58 PM Subject: Re: [AccessD] add numbers > On 12 Apr 2005 at 22:51, Pedro Janssen wrote: > > > Hello Stuart, > > > > thanks for your help. The function works perfect.But i forgot to tell that > > in the field [Para], also "normal" values are present like from 1 to 9. When > > using the function i get an error.on the: While InStr..... I tried to adjust > > the code, with no result. > > > > Me bad, I didn't check for the end of the string in the While Loop. > Try this one instead (watch for line wrap) > > 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 And lngLoopcount <= Len(InputString) > lngLoopcount = lngLoopcount + 1 > Wend > Loop Until lngLoopcount >= Len(InputString) > Addnumbers = lngStore > End Function-- > Stuart > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >