Click here to Skip to main content
15,887,296 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: How to check less then / greater then PinPopular
Nagy Vilmos23-Apr-09 1:38
professionalNagy Vilmos23-Apr-09 1:38 
JokeRe: How to check less then / greater then Pin
Nemanja Trifunovic23-Apr-09 7:57
Nemanja Trifunovic23-Apr-09 7:57 
GeneralRe: How to check less then / greater then Pin
Dan Neely23-Apr-09 8:17
Dan Neely23-Apr-09 8:17 
GeneralRe: How to check less then / greater then Pin
SalarSoft26-Apr-09 1:45
SalarSoft26-Apr-09 1:45 
JokeRe: How to check less then / greater then Pin
Simone Serponi27-Apr-09 3:54
Simone Serponi27-Apr-09 3:54 
GeneralRe: How to check less then / greater then Pin
perels21-Jul-09 13:23
perels21-Jul-09 13:23 
JokeRe: How to check less then / greater then Pin
Simone Serponi27-Apr-09 3:50
Simone Serponi27-Apr-09 3:50 
GeneralWhat would he do if it were floats? Pin
mav.northwind21-Apr-09 20:56
mav.northwind21-Apr-09 20:56 
Found in an article approved not too long ago...
And no, I didn't throw out case 5.

public int Volume
{
  get { return this.volume; }
  set
  {
    if (value < 0) { this.volume = 0; }
    else if (value > 10) { this.volume = 10; }
    else { this.volume = value; }

    //  Set it on Windows Media Player

    //  Fix up

    switch ( this.volume )
    {
      case 0: this.volume = 10; break;
      case 1: this.volume = 9; break;
      case 2: this.volume = 8; break;
      case 3: this.volume = 7; break;
      case 4: this.volume = 6; break;
      case 6: this.volume = 4; break;
      case 7: this.volume = 3; break;
      case 8: this.volume = 2; break;
      case 9: this.volume = 1; break;
      case 10: this.volume = 0; break;
    }
    
    this.volume = this.volume * -100;

    this.player.Volume = this.volume;
    //System.Windows.Forms.MessageBox.Show(this.player.Volume.ToString());
  }
}


Regards,
mav

--
Black holes are the places where God divided by 0...

GeneralRe: What would he do if it were floats? Pin
OriginalGriff21-Apr-09 21:44
mveOriginalGriff21-Apr-09 21:44 
GeneralRe: What would he do if it were floats? Pin
Megidolaon26-Apr-09 21:45
Megidolaon26-Apr-09 21:45 
GeneralRe: What would he do if it were floats? Pin
OriginalGriff26-Apr-09 22:01
mveOriginalGriff26-Apr-09 22:01 
GeneralRe: What would he do if it were floats? Pin
theCPkid26-Apr-09 23:19
theCPkid26-Apr-09 23:19 
GeneralThere are errors and errors... PinPopular
zlezj20-Apr-09 23:32
zlezj20-Apr-09 23:32 
GeneralRe: There are errors and errors... Pin
Yusuf21-Apr-09 8:00
Yusuf21-Apr-09 8:00 
GeneralRe: There are errors and errors... Pin
sonnycheah21-Apr-09 14:32
sonnycheah21-Apr-09 14:32 
GeneralRe: There are errors and errors... Pin
Yusuf21-Apr-09 15:45
Yusuf21-Apr-09 15:45 
GeneralRe: There are errors and errors... Pin
PIEBALDconsult21-Apr-09 8:43
mvePIEBALDconsult21-Apr-09 8:43 
JokeRe: There are errors and errors... Pin
StM0n21-Apr-09 20:28
StM0n21-Apr-09 20:28 
GeneralRe: There are errors and errors... Pin
ricmil4224-Apr-09 3:12
ricmil4224-Apr-09 3:12 
GeneralCharToInt PinPopular
Paulo Zemek17-Apr-09 2:20
mvaPaulo Zemek17-Apr-09 2:20 
GeneralRe: CharToInt Pin
Steve Wellens17-Apr-09 3:42
Steve Wellens17-Apr-09 3:42 
GeneralRe: CharToInt Pin
bulg21-Apr-09 11:12
bulg21-Apr-09 11:12 
GeneralRe: CharToInt Pin
riced17-Apr-09 6:26
riced17-Apr-09 6:26 
JokeRe: CharToInt Pin
Yusuf21-Apr-09 5:11
Yusuf21-Apr-09 5:11 
GeneralRe: CharToInt Pin
Kenneth Ballard17-Apr-09 6:30
Kenneth Ballard17-Apr-09 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.