[AccessD] Math in VBA

Mark A Matte markamatte at hotmail.com
Fri Jul 20 16:13:54 CDT 2007


Actually this wasn't about creating a random number...I using some 'big' 
math to encrypt and decrypt credit card numbers.  It worked perfectly.

Thanks for all of the help.

Mark A. Matte




>From: MartyConnelly <martyconnelly at shaw.ca>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>Subject: Re: [AccessD] Math in VBA
>Date: Fri, 20 Jul 2007 13:36:33 -0700
>
>If you just need a random 16 byte string how about creating a GUID
>
>Private Type GUID
>   Data1 As Long
>   Data2 As Integer
>   Data3 As Integer
>   Data4(7) As Byte
>End Type
>
>Private Declare Function CoCreateGuid Lib "OLE32.DLL" _
>      (pGuid As GUID) As Long
>Private Declare Function StringFromGUID2 Lib "OLE32.DLL" (rguid As GUID, _
>ByVal lpsz As String, cbMax As Long) As Long
>
>'More GUID routines here
>' http://www.trigeminal.com/code/guids.bas
>
>Sub testguid()
>
>   Dim pudtGUID As GUID
>   Dim pstrGUID As String
>   Dim plngRet As Long
>
>   pstrGUID = String(256, 0)
>
>   Debug.Print CoCreateGuid(pudtGUID)
>
>   plngRet = StringFromGUID2(pudtGUID, pstrGUID, Len(pstrGUID))
>   Debug.Print plngRet
>   Debug.Print "GUID = " & Left(pstrGUID, plngRet)
>   Debug.Print pstrGUID
>
>End Sub
>
>Mark A Matte wrote:
>
> >Thanks Everyone,
> >
> >I ended up using a loop to get my powers...before I was the power by 1 
>for
> >each record...now I added a new loop to get the actual number if you
> >calculated out to the nth power.  I was in the quadrillions when I 
>finished.
> >  Thanks Again,
> >
> >Mark
> >
> >    Power = Power - 1
> >    PowerNum = CDec(36)
> >    For PNLoop = 1 To Power - 1
> >    PowerNum = CDec(PowerNum * CDec(36))
> >    Next
> >
> >
> >
> >
> >>From: "Gustav Brock" <Gustav at cactus.dk>
> >>Reply-To: Access Developers discussion and problem
> >>solving<accessd at databaseadvisors.com>
> >>To: <accessd at databaseadvisors.com>
> >>Subject: Re: [AccessD] Math in VBA
> >>Date: Thu, 19 Jul 2007 21:25:42 +0200
> >>
> >>Hi Mark
> >>
> >>Chris is right. You have to keep the _numeric_ expressions within that 
>of a
> >>Long if you wish to maintain accuracy.
> >>
> >>Thus:
> >>? CDec(36 ^10)
> >> 3656158440062980
> >>? CDec(36 ^ 5) * CDec(36 ^ 5)
> >> 3656158440062976
> >>
> >>because CDec(36 ^ 5) = 60466176.
> >>
> >>/gustav
> >>
> >>
> >>
> >>>>>cjeris at fas.harvard.edu 19-07-2007 20:37 >>>
> >>>>>
> >>>>>
> >>-----BEGIN PGP SIGNED MESSAGE-----
> >>Hash: SHA1
> >>
> >>Mark A Matte wrote:
> >>
> >>
> >>>ttt = CDec(36 * 36 * 36)
> >>>
> >>>
> >>6^6 = 46656 overflows a 16-bit signed integer.  Now we can all line up
> >>and kick someone in the head for leaving a 16-bit signed integer type in
> >>a program written after 1995.
> >>
> >>Try
> >>ttt = CDec(36) * CDec(36) * CDec(36)
> >>
> >>Also, be careful!
> >>
> >>
> >>>tt = CDec(36 ^ 10)
> >>>
> >>>
> >>That ^ is the _floating_point_ exponentiation operator!  The result is
> >>not the integer 6^20; if you look at tt, you will see that it ends in a
> >>0, which no power of 6 does.  What you get there is the decimal
> >>conversion of the floating-point exponentiation.
> >>
> >>peace, Chris Jeris
> >>
> >>
>
>--
>Marty Connelly
>Victoria, B.C.
>Canada
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com

_________________________________________________________________
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507




More information about the AccessD mailing list