Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^5: The joys of bad code

by Anonymous Monk
on Oct 28, 2004 at 00:06 UTC ( #403196=note: print w/ replies, xml ) Need Help??

in reply to Re^4: The joys of bad code
in thread The joys of bad code

I thought you were laughing because he used Format(m,"0") in his CASE ELSE statement, while Format(date,"mmm") or Format(date,"mmmm") would have given him the results he was looking for in the first place.

Comment on Re^5: The joys of bad code
Re^6: The joys of bad code (coupling)
by g00n (Hermit) on Oct 28, 2004 at 06:42 UTC

    coupling is something I noticed. if you call *GetMonthName* and pass an arg for the month name, than another arg to abbreviate. The same effect could be obtained writing a formatting function, Format(GetMonthName(arg), "mmm") or even better as you suggest calling Date. having the formatting within the function may be a short cut for now but I bet at sometime changes could be made introducing bugs.

    its also pretty common trap to reimplement (usually poorly) functions that pre-exist.

    Janitored by Arunbear - retitled from 'coupling', as per Monastery guidelines

Re^6: The joys of bad code
by demerphq (Chancellor) on Oct 28, 2004 at 08:11 UTC

    Well, this code has to be locale independent so I actually can sympathise with this approach. We normally deploy onto German Computers but we also end up on various others as well and the output has to be english regardless so I can see why he took this approach than figuring out how to override the users locale settings. (OTOH if you know an easy way to do it im all ears :-)


      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      (OTOH if you know an easy way to do it im all ears :-)
      Maybe SetLocaleInfo() is of help?
      Ah, I was thinking the opposite, that you would want the language to change when you changed the locale settings.

      I don't have anywhere to test it, but if I remember correctly I *think* that if you do the following, it will return formatted U.S. English regardless of system settings.

      Dim dToday As Date dToday = #10/28/2004# MsgBox format(dToday#,"mmm")
      (i.e. Use # rather than " to define your dates. It may be SQL I'm thinking of though... If you have a chance to test it, let me know :) )
        Oops, correction...
        Dim dToday As Date dToday = #10/28/2004# MsgBox format(dToday,"mmm")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://403196]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-08-20 13:32 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (113 votes), past polls