[AccessD] add numbers

Pedro Janssen pedro at plex.nl
Tue Apr 12 15:51:58 CDT 2005


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.

Could you help again.

Thanks

Pedro

----- 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 2:22 PM
Subject: RE: [AccessD] add numbers


> 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
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>





More information about the AccessD mailing list