Click here to Skip to main content
15,910,661 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: Leaky comment? Pin
PIEBALDconsult1-Apr-14 5:32
mvePIEBALDconsult1-Apr-14 5:32 
GeneralRe: Leaky comment? Pin
Rage3-Apr-14 2:06
professionalRage3-Apr-14 2:06 
GeneralRe: Leaky comment? Pin
OriginalGriff3-Apr-14 2:11
mveOriginalGriff3-Apr-14 2:11 
GeneralAnother glittering career falls at the first hurdle PinPopular
A Jordison28-Mar-14 1:10
A Jordison28-Mar-14 1:10 
GeneralRe: Another glittering career falls at the first hurdle Pin
sloosecannon28-Mar-14 4:15
sloosecannon28-Mar-14 4:15 
GeneralRe: Another glittering career falls at the first hurdle Pin
Dave Kreskowiak28-Mar-14 4:16
mveDave Kreskowiak28-Mar-14 4:16 
GeneralRe: Another glittering career falls at the first hurdle Pin
OriginalGriff1-Apr-14 5:00
mveOriginalGriff1-Apr-14 5:00 
GeneralRe: Another glittering career falls at the first hurdle Pin
Nagy Vilmos28-Mar-14 4:29
professionalNagy Vilmos28-Mar-14 4:29 
GeneralRe: Another glittering career falls at the first hurdle Pin
Member 41945932-Apr-14 12:44
Member 41945932-Apr-14 12:44 
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 
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 
Here's my monkey giblets! I knew I still had it somewhere

VB
Function Namecase(ByVal Sourcestring As String) As String
    Dim ConvertChar As Integer, Jock As Integer
    Dim StringLength As Integer, loopvar As Integer
    Dim Newstring As String, Nextchar As String
    Dim MacPos As Integer, Maclen As Integer, TestMac As String

    On Error GoTo HandleErr
    'Lowercase the whole string

    StringLength = Len(Sourcestring)
    Sourcestring = LCase$(Sourcestring)

    For loopvar = 1 To StringLength
        'loop through the string letter by letter and
        'Convert the letter to uppercase if it is :-

        'The First Character in the text box
        ConvertChar = (loopvar = 1)

        'or character following space, hypen or apostrophe
        If Not ConvertChar Then ConvertChar = InStr(" -' ", Mid$(Sourcestring, (loopvar - 1), 1))

        ''or first character following a Mc for the Scots amongst us
        '    If Not ConvertChar Then
        '        If loopvar > 2 Then ConvertChar = (Mid$(SourceString, (loopvar - 2), 2) = "mc")
        '    End If

        Nextchar = Mid$(Sourcestring, loopvar, 1)
        If ConvertChar Then        'Convert character to uppercase if it meets the criteria
            Nextchar = UCase$(Nextchar)
        End If
        Newstring = Newstring & Nextchar        'Concatenate to destination
    Next loopvar
    TestMac = "|" & Newstring & "|"
    MacPos = (InStr("|Machin|Macaskill|Mack|Mackie|Macaly|Macy|Mace|Macari|Macley|Macnamara|Mackay|", TestMac))
    Jock = (MacPos = 0)
    If Jock Then
        MacPos = InStr(Newstring, "Mac")
        Maclen = Len(Newstring)
        If MacPos > 0 Then
            Newstring = left$(Newstring, MacPos + 2) & (UCase$(Mid$(Newstring, MacPos + 3, 1)) & right$(Newstring, (Maclen - (MacPos + 3))))
        End If
        MacPos = InStr(Newstring, "Mc")
        If MacPos > 0 Then
            Newstring = left$(Newstring, MacPos + 1) & (UCase$(Mid$(Newstring, MacPos + 2, 1)) & right$(Newstring, (Maclen - (MacPos + 2))))
        End If
    End If
    Namecase = Newstring        'return the completed string

ExitHere:
    Exit Function

    ' Error handling block added by Error Handler Add-In. DO NOT EDIT this block of code.
    ' Automatic error handler last updated at 09-21-2004 10:35:07   'ErrorHandler:$$D=09-21-2004    'ErrorHandler:$$T=10:35:07
HandleErr:
    Select Case Err.Number
        Case Else
            MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "modFunctions.Namecase"        'ErrorHandler:$$N=modFunctions.Namecase
    End Select
    ' End Error handling block.
End Function

=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================

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.