Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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.

Replies are listed 'Best First'.
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")
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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://403196]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-05-24 20:42 GMT
Find Nodes?
    Voting Booth?