• Keloran (unregistered)

    FrErr(comment + "frist");

  • (cs)

    Doesn't all VBA code look like this?

    HoldIt() does have one mistake. Fred forgot to put a DoEvents in the loop.

  • highphilosopher (unregistered)

    So I have to say that you should expect nothing less that high quality WTF's coming out of an Access Database. It's the breeding ground where they usually start.

  • (cs)

    Well, now I'm finally motivated. I've been meaning to write some kind of function that would, I dunno, maybe "sleep" for a given amount of time or something without sucking up CPU . . . but I'm such a slacker that I've been sitting on my butt instead. Today I will write it! I can already imagine every VB programmer in the world singing my praises.

  • justsomedude (unregistered) in reply to highphilosopher
    highphilosopher:
    So I have to say that you should expect nothing less that high quality WTF's coming out of an Access Database. It's the breeding ground where they usually start.

    The problem isn't that access is horrible, it's great for what it's designed for - and the same applies to VBA. I've built surdy stuff in it when things had to be both simple and fastly done, stuff that ran fine for many years, met the need, and was liked by the end users.

    It's not the platform itself, that it's so accessible, you get a lot of crap built by people that shouldn't be developing in the first place.

  • Ben L. (unregistered)

    I'm broken. I Don't know what happened (I wasn't running at the time), but I called: my mom and bang! The duff code came back with 0: Success. Sorry.

  • Fred (unregistered)

    Sorry, just couldn't HoldIt longish enough

  • Patrick (unregistered)

    You have to at least give credit to Fred for trying out some AI in the error handling. Too bad he basically made an artificial retard...

  • (cs)

    Fred forgot to declare Count Static, so count will never be more than 1 (VB will initialize it to 0 every time it enters the function since when it leaves it goes out of scope because it's not Static).

  • anony mouse (unregistered)

    As the family unpaid computer support guy, I wish more software had a "Have you tried restarting?" built-in suggestion.

  • Nibh (unregistered) in reply to Keloran

    I don't see the WTF. These are EXCELLENT error messages from a usability standpoint. They'd take me from pissed off to laughing in three seconds flat. Really, what other purpose does an error message serve to an end user?

  • filo (unregistered)

    HoldIt is a pseudo random infinite loop generator, nice!

  • BBT (unregistered)

    So, for HoldIt... If you call it in the 59th second of the minute, it's guaranteed to infinitely loop. If you call it with "longish" >= 59, it is guaranteed to infinitely loop. If you call it with "longish" greater than or equal to 59 minus the current second, it will infinitely loop.

    That's one brillant function.

  • (cs)
    1. The MegaQuit() looks a little messy. I'd personally rewrite before it saw a Production db.

    2. That FrErr() looked fine unil I saw the Count variable. (Where did that come from?)

    3. The Sleep() is something I did myself when I was first learning the basics. I dropped it about 5 seconds after running it for the first time.

    Overall, for a first draft, this code looks acceptable. But to send it out to end users? Did Fred Blogs have something issue with the company? His father-in-law perhaps?

  • Timothy Baldridge (unregistered)

    Sorry, I tried to enter the Captcha, but the duff came back with "wrong word".

  • Alargule (unregistered)

    Gregory.

  • Ramses So let it be written so let it be done (unregistered)

    I think all error msgs so say:

    "The application crashed and it's your fault."

    "Reboot your PC."

    There would then also be an animated GIF of Bart Simpson benind over and mooning the user.

  • Ramses So let it be written so let it be done (unregistered) in reply to Ramses So let it be written so let it be done
    Ramses So let it be written so let it be done:
    I think all error msgs should say:

    "The application crashed and it's your fault."

    "Reboot your PC."

    There would then also be an animated GIF of Bart Simpson bending over and mooning the user.

    Sheesh, I type very goodly...

  • MadX (unregistered)

    Someone should try to put that WTF to music. Opera, maybe?

  • Bubba (unregistered)

    A bit of .Net would fix that right up.

  • Paula (unregistered)

    MsgBox("Brillant")

  • NH (unregistered)

    VB (or whatever derivative) and Access is a breeding ground for a whole bunch of WTF:s.

    The least that would happen would have been when an upgrade had occurred rendering the code obsolete.

  • Bob (unregistered) in reply to Paula

    I bet it took you 3 months to come up with that answer.

  • justsomedude (unregistered) in reply to Paula
    Paula:
    PaulaBlog = MsgBox("Brillant",vbYesNo + vbInformation,"Witty")

    FTFY

  • Bob (unregistered) in reply to Paula
    Paula:
    MsgBox("Brillant")
    Helps if I quote it.
  • @Deprecated (unregistered)

    If only my father in law ran a business that I could bilk for piles of money, while getting a monkey to write the code... Then I could sit back and read slashdot all day!

  • DuffMan (unregistered)
    Ramses So let it be written so let it be done:
    There would then also be an animated GIF of Bart Simpson benind over and mooning the user.
    With an error message like "The duff code came back with...", I was thinking more Duff Man than bart...

    "Duffman is thrusting in the direction of the error! Oh Yeah!"

  • (cs)

    this.message = Paula

  • Wyrd (unregistered)

    Ok.

    I get that FrErr() is wonky looking, and it falsely assumes it can rely on Count to hold its previous value the next time its called. Additionally, I'm not sure why a calling count of five was chosen as the magic number that make it switch to the Else clause.

    Also, other people pointed out that HoldIt() acts as a "semi-random infinite loop generator", and even if it were coded properly, it probably shouldn't exist.

    But what precisely is wrong with MegaQuit() beyond its goofiness? There's probably something glaringly horribly wrong with it, but I'm not sure what? Where's the wtf? Please assist. See, one day, I might be the FredBlogs guy and I'd really rather not be, so I need to understand his folly. TIA

    -- Furry cows moo and decompress.

  • Anon (unregistered)

    I think it's brilliant that pause pauses not just Fred's database, but also the entire PC by pinning the CPU.

    If only he had foreseen multi-core PCs and figured out a way to pin all of the processors. Oh well, a craplet developer can dream....

  • Ross (unregistered)

    MegaQuit isn't so bad. Here's two things I can find wrong, but they're not really WTFs.

    First, MegaQuit does two things when it should only do one. One is that it closes all forms; the other is that it asks whether it should quit access, and does so if confirmed. These should be two separate functions.

    The second thing is related. If you're going to quit, why bother closing forms first? And if you do need to close forms before quitting, shouldn't you get confirmation before you start closing them?

  • Christopher (unregistered)

    I'm not at all familiar with VBA... can someone elaborate on what the code does?

  • csm (unregistered) in reply to DuffMan

    this actually made me laugh out loud. high-larious.

  • csm (unregistered) in reply to DuffMan
    DuffMan:
    Ramses So let it be written so let it be done:
    There would then also be an animated GIF of Bart Simpson benind over and mooning the user.
    With an error message like "The duff code came back with...", I was thinking more Duff Man than bart...

    "Duffman is thrusting in the direction of the error! Oh Yeah!"

    ugh...forgot to quote. THIS made me laugh out loud...

  • London Contractor (unregistered) in reply to Ross
    Ross:
    MegaQuit isn't so bad. Here's two things I can find wrong, but they're not really WTFs.

    First, MegaQuit does two things when it should only do one. One is that it closes all forms; the other is that it asks whether it should quit access, and does so if confirmed. These should be two separate functions.

    The second thing is related. If you're going to quit, why bother closing forms first? And if you do need to close forms before quitting, shouldn't you get confirmation before you start closing them?

    I think in Access you need to manually close all the forms before you can quit - also they could be bound to the database, so you'd need to save any changes as well.

    All the code sucks. Awful.

  • Anon (unregistered)

    Anybody writing code like this should be introduced to the MegaFire() function.

  • (cs) in reply to Anon
    Anon:
    Anybody writing code like this should be introduced to the MegaFire() function.

    Nah, he's the VP’s son-in-law. He'll probably use this assignment as a stepping stone to the MegaManager object.

  • (cs) in reply to Ross
    Ross:
    MegaQuit isn't so bad. Here's two things I can find wrong, but they're not really WTFs.

    First, MegaQuit does two things when it should only do one. One is that it closes all forms; the other is that it asks whether it should quit access, and does so if confirmed. These should be two separate functions.

    The second thing is related. If you're going to quit, why bother closing forms first? And if you do need to close forms before quitting, shouldn't you get confirmation before you start closing them?

    It's been a long time (thankfully) since I've done VBA in Access but wouldn't this:

     DoCmd.OpenForm "Start_up"
    

    cause the app to reinitialized running all the Form_Load events rather than just not exiting?

  • Hatterson (unregistered)

    Actually the HoldIt function seems to do exactly what it implies, both by name and comment aside from the obvious error or infinitely looping whenever it's called with longish > 59-current second

    It pauses the application (or freezes it, whichever you prefer). I would also describe it as a Hold as it effectively prevents anything else from happening until it's done.

    It's certainly not a sleep function, but who would want a sleep function that has a duration with a granularity of a second anyway?

    Clearly this is one of the best ways to make sure nothing else happens in your program until you've made frozen everything up for a while.

  • Sponjk (unregistered)

    How, roughly, do you tell "Good" VB from "Bad" VB?

  • (cs)

    If NOT HoldIt() Then PantsWet(true)

  • Rob (unregistered)

    Fred must be quite confused. He can't even give himself a type.

  • (cs) in reply to Sponjk
    Sponjk:
    How, roughly, do you tell "Good" VB from "Bad" VB?

    Well, I guess if it is VB, then it is "Bad" VB. But I may be biased from a sample size of little less than a hundred applications, writen by nearly two hundred people (some that also write on other languages) I've seen on my life. Any sample size is too small to prove an absolute...

    The funny thing is that some of those people that code on more than one language write good code on the other languages.

  • VictorSierraGolf (unregistered) in reply to Sponjk
    Sponjk:
    How, roughly, do you tell "Good" VB from "Bad" VB?

    Uh... WTFs per minute, maybe?

  • S. Palin (unregistered) in reply to Patrick

    Now lets not go insulting all those who are mentally challenged. They are much smarter than that error handling.

    Patrick:
    You have to at least give credit to Fred for trying out some AI in the error handling. Too bad he basically made an artificial retard...
  • rfoxmich (unregistered) in reply to VictorSierraGolf

    WTF/KLOC is the standard measure. Problem is that number is usually >> 1

  • (cs) in reply to rfoxmich
    rfoxmich:
    WTF/KLOC is the standard measure. Problem is that number is usually >> 1

    1 WTF per 1000 lines of code isn't bad at all. That's got me beat.

  • Tim E Kaard (unregistered) in reply to Sponjk
    Sponjk:
    How, roughly, do you tell "Good" VB from "Bad" VB?
    Easy. "Bad" VB typically uses a random sample of bytes from the ASCII character set. "Good" VB uses only whitespace.
  • Fred Blogs (unregistered) in reply to Anon
    Anon:
    I think it's brilliant that pause pauses not just Fred's database, but also the entire PC by pinning the CPU.

    If only he had foreseen multi-core PCs and figured out a way to pin all of the processors. Oh well, a craplet developer can dream....

    I think it is quite unfair of you guys to pick on my code when all you have is a few excerpts, and only one side of the story.

    Let's just say we don't hire the brightest users at my father-in-law's company. He's widely known as a tightwad and won't hire anyone for more than minimum wage. Then he forbids outside food and drink, and puts in his own vending machines with $2.00 sodas and $7.50 sandwiches. So ultimately the only people who will work here are those who can't do any math. Hell, they can barely count. And read? Forgetaboudit.

    Hence my challenge. When an error message occurs they just ignore it. So I was asked to make them more amusing. No effect. They skip right by them. Finally, old skinflint himself told me -- not asked -- to lock up their computer after every error so they can't do anything else until they read the frickin screen already goddammit!

  • Hexadecima (unregistered) in reply to BBT
    BBT:
    So, for HoldIt... If you call it in the 59th second of the minute, it's guaranteed to infinitely loop. If you call it with "longish" >= 59, it is guaranteed to infinitely loop. If you call it with "longish" greater than or equal to 59 minus the current second, it will infinitely loop.

    That's one brillant function.

    ACTUALLY, HoldIt() would only loop for a minute, not infinitely. Seriously you guys. Seriously.

Leave a comment on “Fred Blogs' MegaQuit()”

Log In or post as a guest

Replying to comment #:

« Return to Article