Propercase in

Posted on 2011-10-25
Last Modified: 2012-05-12
I understand this sample help to take care of string to proper case.

johne doe to John Doe

Is there a proper way of handling lastname such as mcdonalds to McDonalds? john doe II to John Doe II
Should I check the first two char if mc then change to Mc and if ii change to II ?

            Dim mystring = "john mcdonalds v "
        Dim FL As String = mystring.Trim
        If FL.Contains(" ") Then
            FL = StrConv(FL, VbStrConv.ProperCase)
            Dim ar_II As String() = FL.Split(" ")
            Dim mystr As String
            Dim nustr As String = ""
            For Each mystr In ar_II    
                If mystr.StartsWith("Mc") Then
                    Dim I As Integer = mystr.Length
                    If I > 2 Then
                        mystr = mystr.Substring(0, 2) & StrConv(mystr.Substring(2), VbStrConv.ProperCase)
                    End If
                End If
                Select Case mystr.ToLower
                    Case "i"
                        mystr = mystr.ToUpper
                    Case "ii"
                        mystr = mystr.ToUpper
                    Case "iii"
                        mystr = mystr.ToUpper
                    Case "v"
                        mystr = mystr.ToUpper
                    Case "vi"
                        mystr = mystr.ToUpper
                End Select
                nustr &= mystr & " "
            FL = StrConv(FL, VbStrConv.ProperCase)
        End If
Question by:VBdotnet2005
    LVL 83

    Accepted Solution

    I dont think there is a built in way of dealing with names like mcdonalds. So this would require some if else conditions.
    LVL 43

    Expert Comment

    by:Saqib Husain, Syed

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now