Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Why? Just why?

Why? Just why?

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpquestioncareer
27 Posts 14 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nagy Vilmos

    I know, lets keep re-comparing strings as it's cheap and easy. Thank you VB6; the gift that keeps on giving.

    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

    C Offline
    C Offline
    Chris Quinn
    wrote on last edited by
    #5

    I wrote a very similar routine for Access many years ago, but it's better as it handles special cases like 'Macari' and 'Macy' which this routine would render as 'MacAri ' and 'MacY'

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

    N 1 Reply Last reply
    0
    • C Chris Quinn

      I wrote a very similar routine for Access many years ago, but it's better as it handles special cases like 'Macari' and 'Macy' which this routine would render as 'MacAri ' and 'MacY'

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

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #6

      It still sucks monkey giblets

      C 1 Reply Last reply
      0
      • N Nagy Vilmos

        It still sucks monkey giblets

        C Offline
        C Offline
        Chris Quinn
        wrote on last edited by
        #7

        Here's my monkey giblets! I knew I still had it somewhere

        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, vbCritic

        J B M 3 Replies Last reply
        0
        • C Chris Quinn

          Here's my monkey giblets! I knew I still had it somewhere

          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, vbCritic

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #8

          How about McHammer? :doh:

          Wrong is evil and must be defeated. - Jeff Ello[^]

          N 1 Reply Last reply
          0
          • J Jorgen Andersson

            How about McHammer? :doh:

            Wrong is evil and must be defeated. - Jeff Ello[^]

            N Offline
            N Offline
            Nagy Vilmos
            wrote on last edited by
            #9

            Stop!

            J 1 Reply Last reply
            0
            • C Chris Quinn

              Here's my monkey giblets! I knew I still had it somewhere

              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, vbCritic

              B Offline
              B Offline
              BobJanova
              wrote on last edited by
              #10

              MacAskill and (definitely) MacNamara look like they are real Macs. This kind of code just implies your input and/or requirements are crap, though. People should be trusted to type their own name as they want it.

              N C 2 Replies Last reply
              0
              • B BobJanova

                MacAskill and (definitely) MacNamara look like they are real Macs. This kind of code just implies your input and/or requirements are crap, though. People should be trusted to type their own name as they want it.

                N Offline
                N Offline
                Nagy Vilmos
                wrote on last edited by
                #11

                This goes back to a more elegant age where people couldn't use puters.

                1 Reply Last reply
                0
                • N Nagy Vilmos

                  Stop!

                  J Offline
                  J Offline
                  Jorgen Andersson
                  wrote on last edited by
                  #12

                  I'm Too Legit to Quit, I Don't Stop until I'm Gaining Momentum. So Feel My Power it's Hammertime.

                  Wrong is evil and must be defeated. - Jeff Ello[^]

                  1 Reply Last reply
                  0
                  • N Nagy Vilmos

                    I know, lets keep re-comparing strings as it's cheap and easy. Thank you VB6; the gift that keeps on giving.

                    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

                    B Offline
                    B Offline
                    Bernhard Hiller
                    wrote on last edited by
                    #13

                    Well, you have to run that code at the speed of MacH 2.

                    1 Reply Last reply
                    0
                    • B BobJanova

                      MacAskill and (definitely) MacNamara look like they are real Macs. This kind of code just implies your input and/or requirements are crap, though. People should be trusted to type their own name as they want it.

                      C Offline
                      C Offline
                      Chris Quinn
                      wrote on last edited by
                      #14

                      I have a Scottish friend called Macaskill who definitely does not capitalise internally, and the others were ascertained by looking through the telephone directories of several major British cities, though I think Macnamara[^] is a special special case - some capitalise and some don't

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

                      1 Reply Last reply
                      0
                      • N Nagy Vilmos

                        I know, lets keep re-comparing strings as it's cheap and easy. Thank you VB6; the gift that keeps on giving.

                        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

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #15

                        You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                        A guide to posting questions on CodeProject

                        How to debug small programs
                        Dave Kreskowiak

                        N B Z C B 6 Replies Last reply
                        0
                        • D Dave Kreskowiak

                          You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                          A guide to posting questions on CodeProject

                          How to debug small programs
                          Dave Kreskowiak

                          N Offline
                          N Offline
                          Nagy Vilmos
                          wrote on last edited by
                          #16

                          No, that hurt.

                          1 Reply Last reply
                          0
                          • D Dave Kreskowiak

                            You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                            A guide to posting questions on CodeProject

                            How to debug small programs
                            Dave Kreskowiak

                            B Offline
                            B Offline
                            BobJanova
                            wrote on last edited by
                            #17

                            Oh my word.

                            1 Reply Last reply
                            0
                            • D Dave Kreskowiak

                              You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                              A guide to posting questions on CodeProject

                              How to debug small programs
                              Dave Kreskowiak

                              Z Offline
                              Z Offline
                              ZurdoDev
                              wrote on last edited by
                              #18

                              I'm surprised that CP didn't give an "Out of memory exception" when the OP posted that code. Whew!

                              There are only 10 types of people in the world, those who understand binary and those who don't.

                              1 Reply Last reply
                              0
                              • D Dave Kreskowiak

                                You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                                A guide to posting questions on CodeProject

                                How to debug small programs
                                Dave Kreskowiak

                                C Offline
                                C Offline
                                Chris Quinn
                                wrote on last edited by
                                #19

                                As I always say, it ain't the tool that is used that's the problem, but the tool that uses it.

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

                                1 Reply Last reply
                                0
                                • C Chris Quinn

                                  Here's my monkey giblets! I knew I still had it somewhere

                                  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, vbCritic

                                  M Offline
                                  M Offline
                                  MarkTJohnson
                                  wrote on last edited by
                                  #20

                                  Glad to see it takes care of MacHine

                                  1 Reply Last reply
                                  0
                                  • N Nagy Vilmos

                                    I know, lets keep re-comparing strings as it's cheap and easy. Thank you VB6; the gift that keeps on giving.

                                    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

                                    M Offline
                                    M Offline
                                    mikepwilson
                                    wrote on last edited by
                                    #21

                                    Holy crap. Here's what you do. Install Strawberry Perl on that machine, and have that function shell out to a perl one-liner. It'll still be more efficient and less dain bramaged.

                                    N 1 Reply Last reply
                                    0
                                    • M mikepwilson

                                      Holy crap. Here's what you do. Install Strawberry Perl on that machine, and have that function shell out to a perl one-liner. It'll still be more efficient and less dain bramaged.

                                      N Offline
                                      N Offline
                                      Nagy Vilmos
                                      wrote on last edited by
                                      #22

                                      mikepwilson wrote:

                                      Install Strawberry Perl

                                      No, I don't think so...

                                      mikepwilson wrote:

                                      less dain bramaged

                                      you were saying? :laugh:

                                      M 1 Reply Last reply
                                      0
                                      • N Nagy Vilmos

                                        mikepwilson wrote:

                                        Install Strawberry Perl

                                        No, I don't think so...

                                        mikepwilson wrote:

                                        less dain bramaged

                                        you were saying? :laugh:

                                        M Offline
                                        M Offline
                                        mikepwilson
                                        wrote on last edited by
                                        #23

                                        I dunno man, consider it. Perl is the language for programmers who have actual work to get done.

                                        1 Reply Last reply
                                        0
                                        • D Dave Kreskowiak

                                          You thought that code was bad?? How about this[^] little gem, written in C#?? I hate hearing crap about VB being the sole domain of horrible code.

                                          A guide to posting questions on CodeProject

                                          How to debug small programs
                                          Dave Kreskowiak

                                          B Offline
                                          B Offline
                                          Brisingr Aerowing
                                          wrote on last edited by
                                          #24

                                          :wtf:

                                          What do you get when you cross a joke with a rhetorical question?

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups