Click here to Skip to main content
15,886,919 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: Another glittering career falls at the first hurdle Pin
ZurdoDev28-Mar-14 5:07
professionalZurdoDev28-Mar-14 5:07 
GeneralRe: Another glittering career falls at the first hurdle Pin
PIEBALDconsult28-Mar-14 6:54
mvePIEBALDconsult28-Mar-14 6:54 
GeneralRe: Another glittering career falls at the first hurdle Pin
Bernhard Hiller30-Mar-14 23:07
Bernhard Hiller30-Mar-14 23:07 
GeneralRe: Another glittering career falls at the first hurdle Pin
BobJanova31-Mar-14 1:17
BobJanova31-Mar-14 1:17 
GeneralRe: Another glittering career falls at the first hurdle Pin
PIEBALDconsult31-Mar-14 9:45
mvePIEBALDconsult31-Mar-14 9:45 
GeneralRe: Another glittering career falls at the first hurdle Pin
0bx1-Apr-14 4:27
0bx1-Apr-14 4:27 
GeneralRe: Another glittering career falls at the first hurdle Pin
TheGreatAndPowerfulOz3-Apr-14 6:02
TheGreatAndPowerfulOz3-Apr-14 6:02 
GeneralWhy? Just why? Pin
Nagy Vilmos24-Mar-14 23:24
professionalNagy Vilmos24-Mar-14 23:24 
I know, lets keep re-comparing strings as it's cheap and easy. Thank you VB6; the gift that keeps on giving.

VB
Public Function sConvertCase(sInString, lType As VbStrConv) As String
Dim sReturn As String
Dim lPos As Long
Dim lStart As Long
Dim lNext As Long
On Local Error Resume Next
    sReturn = StrConv(sInString, lType)
    If lType = vbProperCase Then
        'check for This-That, O'Sumin ,McSumin, von Sumin, MacName (must be input as MacN...)
        lPos = 0
        Do
            lStart = lPos + 1
            lPos = InStr(lStart, sReturn, "Mc")
            lNext = InStr(lStart, sReturn, "Mac")
            If lNext > 0 And (lNext < lPos Or lPos = 0) Then
                lPos = lNext
            End If
            lNext = InStr(lStart, sReturn, "O'")
            If lNext > 0 And (lNext < lPos Or lPos = 0) Then
                lPos = lNext
            End If
            lNext = InStr(lStart, sReturn, "Von ")
            If lNext > 0 And (lNext < lPos Or lPos = 0) Then
                lPos = lNext
            End If
            lNext = InStr(lStart, sReturn, "-")
            If lNext > 0 And lNext < lPos Or lPos = 0 Then
                lPos = lNext
            End If

            If lPos = 0 Then
            ElseIf Mid$(sReturn, lPos, 1) = "-" Then
                Mid$(sReturn, lPos + 1, 1) = UCase$(Mid$(sReturn, lPos + 1, 1))
            ElseIf Mid$(sReturn, lPos, 2) = "Mc" Then
                Mid$(sReturn, lPos + 2, 1) = UCase$(Mid$(sReturn, lPos + 2, 1))
            ElseIf Mid$(sReturn, lPos, 3) = "Mac" Then
                If Mid$(sInString, lPos, 3) = "Mac" And Mid$(sInString, lPos + 3, 1) = UCase$(Mid$(sInString, lPos, 3)) Then
                    Mid$(sReturn, lPos + 3, 1) = UCase$(Mid$(sReturn, lPos + 3, 1))
                End If
            ElseIf Mid$(sReturn, lPos, 2) = "O'" Then
                Mid$(sReturn, lPos + 2, 1) = UCase$(Mid$(sReturn, lPos + 2, 2))
            ElseIf Mid$(sReturn, lPos, 4) = "Von " Then
                Mid$(sReturn, lPos, 1) = "v"
            End If
        Loop While lPos > 0
    End If
Done:
    sConvertCase = sReturn
End Function

GeneralRe: Why? Just why? Pin
Kornfeld Eliyahu Peter25-Mar-14 0:03
professionalKornfeld Eliyahu Peter25-Mar-14 0:03 
GeneralRe: Why? Just why? Pin
Nagy Vilmos25-Mar-14 0:33
professionalNagy Vilmos25-Mar-14 0:33 
GeneralRe: Why? Just why? Pin
Argonia25-Mar-14 1:29
professionalArgonia25-Mar-14 1:29 
GeneralRe: Why? Just why? Pin
Rob Grainger31-Mar-14 2:06
Rob Grainger31-Mar-14 2:06 
GeneralRe: Why? Just why? Pin
Fueled By Decaff1-Apr-14 2:08
Fueled By Decaff1-Apr-14 2:08 
GeneralRe: Why? Just why? Pin
Chris Quinn25-Mar-14 1:44
Chris Quinn25-Mar-14 1:44 
GeneralRe: Why? Just why? Pin
Nagy Vilmos25-Mar-14 2:13
professionalNagy Vilmos25-Mar-14 2:13 
GeneralRe: Why? Just why? Pin
Chris Quinn25-Mar-14 4:31
Chris Quinn25-Mar-14 4:31 
GeneralRe: Why? Just why? Pin
Jörgen Andersson25-Mar-14 5:00
professionalJörgen Andersson25-Mar-14 5:00 
GeneralRe: Why? Just why? Pin
Nagy Vilmos25-Mar-14 6:24
professionalNagy Vilmos25-Mar-14 6:24 
GeneralRe: Why? Just why? Pin
Jörgen Andersson25-Mar-14 9:30
professionalJörgen Andersson25-Mar-14 9:30 
GeneralRe: Why? Just why? Pin
BobJanova25-Mar-14 6:28
BobJanova25-Mar-14 6:28 
GeneralRe: Why? Just why? Pin
Nagy Vilmos25-Mar-14 6:48
professionalNagy Vilmos25-Mar-14 6:48 
GeneralRe: Why? Just why? Pin
Chris Quinn25-Mar-14 22:00
Chris Quinn25-Mar-14 22:00 
GeneralRe: Why? Just why? Pin
MarkTJohnson26-Mar-14 6:53
professionalMarkTJohnson26-Mar-14 6:53 
GeneralRe: Why? Just why? Pin
Bernhard Hiller25-Mar-14 21:49
Bernhard Hiller25-Mar-14 21:49 
GeneralRe: Why? Just why? PinPopular
Dave Kreskowiak26-Mar-14 4:29
mveDave Kreskowiak26-Mar-14 4:29 

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.