Click here to Skip to main content
15,890,512 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: PL SQL INTO Horror Pin
David Skelly6-Sep-10 3:33
David Skelly6-Sep-10 3:33 
GeneralTesting the null PinPopular
bourdiitsme31-Aug-10 5:52
bourdiitsme31-Aug-10 5:52 
GeneralRe: Testing the null PinPopular
OriginalGriff31-Aug-10 8:17
mveOriginalGriff31-Aug-10 8:17 
GeneralRe: Testing the null Pin
AspDotNetDev31-Aug-10 8:21
protectorAspDotNetDev31-Aug-10 8:21 
GeneralRe: Testing the null PinPopular
OriginalGriff31-Aug-10 8:35
mveOriginalGriff31-Aug-10 8:35 
GeneralRe: Testing the null Pin
supercat93-Sep-10 7:23
supercat93-Sep-10 7:23 
GeneralRe: Testing the null Pin
bourdiitsme7-Sep-10 0:14
bourdiitsme7-Sep-10 0:14 
GeneralVB 6 PinPopular
Lutosław28-Aug-10 1:22
Lutosław28-Aug-10 1:22 
Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror.

This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart.

I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

Private Sub Command1_Click()
 x = InputBox("Enter a name or a nick:", "Name?!", nz)
 If x = "" Then Exit Sub
 nz = x
 kon = False
 Command3.Enabled = True
 Command4.Enabled = True
 dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
 odp.Interval = Text5 * 1000
 Label1 = ""
 Label8 = ""
 Label1.Visible = True
 il = 0
 oc = 6
' Combo2.AddItem "0 - First component (denary)"
' Combo2.AddItem "1 - Both components (denary)"
' Combo2.AddItem "2 - First component (hundredth)"
' Combo2.AddItem "3 - Both components (hundredth)"  <== whatever that means... ;)
If Check1 = 1 Then
 ul = Combo2.ListIndex
Else
 ul = 124
End If
1:
 Randomize
 d1 = Int((Text2 + 1) * Rnd)
 Randomize  // randomize every time -- that time I though that it would give "more random" numbers...
 d2 = Int((Text3 + 1) * Rnd)
 Randomize
 If Check2 = 1 Then
  rd = Int((4) * Rnd + 1)
 Else
  rd = Int((2) * Rnd + 1)
 End If
 If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
 Randomize
 If ul = 0 Or ul = 1 Then
  a = Int((9 + 1) * Rnd)
  a = Left(a, 1)
  c = Str(d1)
  c = c & "." & Str(a)  //Whoa...
  d1 = CDbl(c)
 End If
 If ul = 1 Then
  a = Int((9 + 1) * Rnd)
  a = Left(a, 1)
  c = Str(d2)
  c = c & "." & Str(a)
  d2 = CDbl(c)
 End If
 If ul = 2 Or ul = 3 Then
  a = Int((99 + 1) * Rnd)
  a = Left(a, 2)
  c = Str(d1)
  c = c & "." & Str(a)
  d1 = CDbl(c)
 End If
 If ul = 3 Then
  a = Int((99 + 1) * Rnd)
  a = Left(a, 2)
  c = Str(d2)
  c = c & "." & Str(a)
  d2 = CDbl(c)
 End If
 If rd = 1 Then
  w = d1 * d2
  Label1 = d1 & " times " & d2 & " =?"
 ElseIf rd = 2 Then
  w = d2
  Label1 = d1 * d2 & " divided by " & d1 & " =?"
 ElseIf rd = 3 Then
  w = d1 + d2
  Label1 = d1 & " add " & d2 & " =?"
 ElseIf rd = 4 Then
  w = d1 - d2
  Label1 = d1 & " minus " & d2 & " =?"
 End If
 dzial.Enabled = True
 odp.Enabled = True
 Command4.Enabled = False
 Frame1.Enabled = False
 Text1.SetFocus
 Text1.SelStart = 0
 Text1.SelLength = Len(Text1)
 Command2.Enabled = False
End Sub

A correct answer was stored in a global variable "w".
A user could even set adifficulty level!:
Private Sub Combo1_Click()
 Select Case Combo1.Text
  Case "Easy"
   Text2 = 10
   Text3 = 12
   Text4 = 9
   Text5 = 28
   Text6 = 11
   Check1 = 1
   Combo2.ListIndex = 0
  Case "Elementary"
   Text2 = 9
   Text3 = 9
   Text4 = 3
   Text5 = 20
   Check1 = 0
   Combo2.ListIndex = 0
   Text6 = 14
  Case "Medium"
   Text2 = 13
   Text3 = 14
   Text4 = 14
   Text5 = 35
   Text6 = 15
   Check1 = 1
   Combo2.ListIndex = 1
  Case "Hard"
   Text2 = 15
   Text3 = 15
   Text4 = 30
   Text5 = 50
   Text6 = 16
   Check1 = 1
   Combo2.ListIndex = 2
  Case "Impossible to finish" // btw it was impossible indeed, tasks whas like "238.68/76.01"
   Text2 = 18
   Text3 = 19
   Text4 = 60
   Text5 = 60
   Text6 = 20
   Check1 = 1
   Combo2.ListIndex = 3
 End Select
End Sub

Greetings - Jacek

GeneralRe: VB 6 Pin
Bigdeak29-Aug-10 23:44
Bigdeak29-Aug-10 23:44 
GeneralRe: VB 6 PinPopular
Chris Trelawny-Ross30-Aug-10 10:43
Chris Trelawny-Ross30-Aug-10 10:43 
GeneralRe: VB 6 PinPopular
PIEBALDconsult30-Aug-10 16:47
mvePIEBALDconsult30-Aug-10 16:47 
GeneralRe: VB 6 Pin
Lutosław30-Aug-10 23:03
Lutosław30-Aug-10 23:03 
GeneralRe: VB 6 Pin
Chris Trelawny-Ross31-Aug-10 4:05
Chris Trelawny-Ross31-Aug-10 4:05 
GeneralRe: VB 6 PinPopular
Richard A. Dalton31-Aug-10 0:15
Richard A. Dalton31-Aug-10 0:15 
JokeRe: VB 6 Pin
Chris Meech31-Aug-10 8:37
Chris Meech31-Aug-10 8:37 
GeneralRe: VB 6 Pin
Rob Grainger31-Aug-10 22:37
Rob Grainger31-Aug-10 22:37 
GeneralRe: VB 6 Pin
jmoralesv1-Sep-10 17:14
professionaljmoralesv1-Sep-10 17:14 
GeneralRe: VB 6 Pin
Lutosław31-Aug-10 22:28
Lutosław31-Aug-10 22:28 
GeneralRe: VB 6 Pin
Rob Grainger31-Aug-10 22:59
Rob Grainger31-Aug-10 22:59 
GeneralRe: VB 6 Pin
sergiogarcianinja1-Sep-10 7:00
sergiogarcianinja1-Sep-10 7:00 
GeneralRe: VB 6 Pin
Rob Grainger1-Sep-10 22:11
Rob Grainger1-Sep-10 22:11 
GeneralRe: VB 6 Pin
edmurphy991-Sep-10 7:29
edmurphy991-Sep-10 7:29 
GeneralRe: VB 6 Pin
OriginalGriff1-Sep-10 8:13
mveOriginalGriff1-Sep-10 8:13 
RantRe: VB 6 Pin
Thomas Eyde4-Sep-10 10:38
Thomas Eyde4-Sep-10 10:38 
GeneralRe: VB 6 Pin
OriginalGriff4-Sep-10 10:43
mveOriginalGriff4-Sep-10 10:43 

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.