Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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]
[LanX]: Sinai_Peninsula
[robby_dobby]: choroba: If you're talking of Eurasia, it's only true of the erstwhile Constantinople/ Ottoman empire
[LanX]: yes correct, but Sinai is not on the other side
[LanX]: Organizing a YAPC in a tourist ressort is not a bad idea ...
[LanX]: ... and we could swap to our first YAPC Africa the following year when organizing in Hurghada
[robby_dobby]: LanX: Well volunteered!
[LanX]: ... just ... ppl would be to afraid of terrorist attacks
[choroba]: python guerrila?
[robby_dobby]: if I do make it, I can at least savour their local tea! :-)
[LanX]: oh they have sleper cells everywhere

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2017-04-24 16:07 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (442 votes). Check out past polls.