Scott Marcus
marcus at tsstech.com
Thu Aug 12 12:39:56 CDT 2004
How about calculating when a year is a leap year? Public Function bolIsYear366DaysThereforeALeapYear(ByVal _ lngYearYouWantToCheck As Long) As Boolean Dim bolTrueOrFalseValue As Boolean If DateDiff("d", DateSerial(lngYearYouWantToCheck, 1, 1), _ DateSerial(lngYearYouWantToCheck, 12, 31)) = 365 Then bolTrueOrFalseValue = True Else bolTrueOrFalseValue = False End If bolIsYear366DaysThereforeALeapYear = bolTrueOrFalseValue End Function --OR-- Public Function LeapYear(ByVal i As Long) As Boolean Dim ly As Boolean If DateDiff("d", DateSerial(i, 1, 1), _ DateSerial(i, 12, 31)) = 365 Then ly = True Else ly = False End If LeapYear = ly End Function -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Thursday, August 12, 2004 1:14 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Announcing (Proposing) the First Annual DBA AccessObfuscation Contest The Naming Conventions thread has been most interesting and has prompted me to suggest an annual contest a la the classic DDJ C-Obfuscation contest. The point is to write a geruinely incomprehensible routine that does something useful. It would only make sense if we confined ourselves to say 5 candidate routines, Access-specific of course. Contributors could then submit a "solution" to any of the 5 problems. (A double-prize might be considered for code that does not even make it apparent which problem it is solving!) Step 1 is to gather the list of problems. I venture the following merely as a starting point. I haven't given any of them a lot of consideration, they are nothing more than something to shoot at, if you will. Somehow let's settle on 5 problems worth obfuscating. After that, obfuscation will be, heh heh, obvious. Herewith, 5 problems. Please feel free to shoot them down as insignificant or not worth writing etc. I would love to have the list come up with 5 genuinely interesting problems, on which to base the obfuscated solutions. None of them would be immediately useful in anyone's current project, but I think it would be fun to see the variants that contestants come up with. Five initial examples. Fire at will. Please come up with more interesting problems! 1. For every open form for every textbox make it read-only change the colours 2. Given tables Parent and Child, delete every third Parent record and all her children in the Child table. 3. Manufacture some test data in 4 tables: parent, child1, child2, and child2's child. The routine accepts the number of parents to create and the maximum number of child rows to create. Then it randomly adds kids (and grandkids) to tables 2, 3 and 4 for each parent, using the specified maximum. 4. Delete every file from every directory to which the user has access, while presenting warm and fuzzy messages. (Don't really delete them, just print a message suggesting that could have. Option: Tell them you HAVE deleted them, and offer recovery for $.05 a file. Bring up PayPal to complete the transaction. 5. Create an email to every person in your Outlook Contacts folder, announcing that your surgery was unsuccessful and you are now a refridgerator salesperson in Resolute Bay. Five stupid problems, I admit. Let's come up with five smart problems and then obfuscate their solutions! (At the least, each problem could become an issue of our newsletter, including the various solutions sent in by listers.) One obvious obfuscation technique is purposeful misuse of Hungarian. Dim strValue as Long ' the number of striations per meter of a given cave wall. Dim datLast as Currency ' how much you paid the hooker for your last "date". Dim booLevel as Byte ' scare factor in a horror movie focus group. Dim booLevel as Long ' WWE measurement as reported by microphones. Dim cboAvail as Boolean ' is this jazz musician available for work in a combo? But there are many more. Table names offer abundant opportunities to play. You get the idea, I hope.... Arthur -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com