From: Mike Williams on 13 Sep 2009 23:36 "Kevin Provance" wrote in message news:ODZi%23XNNKHA.1372(a)TK2MSFTNGP02.phx.gbl... > Maybe it's my entry into the world of Basic at VB3 (does > graphics work on an Apple IIe count?) but not once have > I ever used GoSub. Never. When I started with Basic there was no choice. You either used Gosub or you didn't code ;-) Mike From: Rick Rothstein on 14 Sep 2009 10:58 I just noticed that I forgot to change the assignment inside the function from my test name (Oneliner) to the actual function name I ended up using (MakeOrdinal)... so that would need to be done for the code I posted previously. However, in thinking about it some more, we can make this function a *true* one-liner by getting rid of the IIf function call as follows (I don't consider using IIf a *pure* one liner as it is just an If..Then...Else block in disguise)... Function MakeOrdinal(Number As Long) As String MakeOrdinal = Number & Choose(1 + Number * Abs(Partition(Number Mod _ 100, 1, 13, 5) <> "11:13" And Partition(Number Mod 10, _ 1, 9, 3) = " 1: 3") Mod 10, "th", "st", "nd", "rd") End Function There... now we have a *true* one-liner... I feel much better. -- Rick (MVP - Excel) "Rick Rothstein" wrote in message news:egPfDUONKHA.1796(a)TK2MSFTNGP02.phx.gbl...> This one-liner function doesn't use On...GoTo, but I'm pretty sure it > would qualify as being somewhat obfuscated... > > Function MakeOrdinal(Number As Long) As String > Oneliner = Number & IIf(Partition(Number Mod 100, 1, 13, 5) <> _ > "11:13" And Partition(Number Mod 10, 1, 9, 3) = " 1: 3", _ > Choose(Number Mod 10, "st", "nd", "rd"), "th") > End Function > > It should be obvious, but in case it isn't, this function takes a number > and attaches the proper ordinal suffix (st, nd, rd, th) to the end of it. > Now, your challenge... explain the logic behind the function. > > -- > Rick (MVP - Excel) > > > "Ralph" wrote in message > news:uAOcEBONKHA.220(a)TK2MSFTNGP02.phx.gbl... >> >> "Rick Rothstein" wrote in message >> news:OG8UdfNNKHA.1372(a)TK2MSFTNGP02.phx.gbl... >>> > Two of my favorites, although definitely NOT new, but especially >>> > fun at code reviews populateds with Bobs, et al, is >>> > On ... Goto and On ... GoSub >>> > >>> > Add a few Switches and Chooses and you can come close to >>> > an legitimate Obfuscated Code entry. >>> >>> I wouldn't know anything about that... I think I can say with all >> confidence >>> that I have never written any obfuscated code in my life. >>> >>> >>> >> >> Ahhhh, the ultimate >> >> A On...Goto leading to a selection of one-liners, ending with a >> conditional >> Choose(). >> >> -ralph >> >> > From: Ralph on 14 Sep 2009 13:02 Rick Rothstein wrote:> >> Now, your challenge... explain the logic behind the function. >> Surely you jest. I have long considered your one-liners as write-only magical spells to be invoked when or where needed. -ralph From: Rick Rothstein on 14 Sep 2009 16:35 >>> Now, your challenge... explain the logic behind the function.>>> > > Surely you jest. Judging by your next statement below, I'm guessing how it works is not an important consideration to you. > I have long considered your one-liners as write-only magical spells to be > invoked when or where needed. LOL ... Yeah, sometimes even I marvel over some of the constructions I come up with. -- Rick (MVP - Excel) From: David Kaye on 14 Sep 2009 21:28 I will be writing a little multiple stopwatch program soon. It'll keep track of 6 timed events at once. One thing that'll be handy is creating a static array within a procedure that is only called when the particular stopwatch is clicked on or off. Click it once and the the array starts incrementing. Click it again and it stops incrementing. That can be done with one command button (for each stopwatch) and setting up a static stopwatch variable and a not statement. I'm thinking, static StopWatchTime(6) as date static StopWatch%(6) and the command button procedure would be something like StopWatch%(MyStopwatch%) = not StopWatch%(MyStopwatch%) if StopWatch%(MyStopwatch%) then 'whatever process you'd use to increment the stopwatch Should be fairly easy to whip out. -- "You're in probably the wickedest, most corrupt city, most Godless city in America." -- Fr Mullen, "San Francisco" First  |  Prev  |