Link to home
Create AccountLog in
Avatar of itortu
itortuFlag for United States of America

asked on

formatting first and last names.

how can I apply the formatting of the first and last names inside the property declaration intead that going to the formatting function?

Public Property Name() As String
        Get
            Return m_strFirstName & m_strLastName
        End Get
        Set(ByVal vData As String)
            m_strLastName = Format_FixedString(Trim(Mid(vData, 19, 15)), 15, eFixedFormatTypes.fftAlphaNumeric)
            m_strFirstName = Format_FixedString(Trim(Mid(vData, 1, 15)), 15, eFixedFormatTypes.fftAlphaNumeric)
        End Set
    End Property

thank you.
Avatar of cheddar73
cheddar73

Can you describe the format you are looking for in words rather than "Format_FixedString(Trim(Mid(vData, 19, 15)), 15, eFixedFormatTypes.fftAlphaNumeric)"?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I am do sure what you are looking for in the style of how you want the First Last name
So here is some code that I used in the past on looking for and adjusting  names.

Imports System.Text.RegularExpressions
  'strName =  "Last,First MI"
    Private Sub UseRegularExpression(ByVal strName As String)
        Dim regExp As New Regex("([a-zA-Z]{1,})\,{1}\s{0,}([a-zA-Z]{1,})\s{0,}([a-zA-Z]{0,})")
        Dim matchGroups As GroupCollection = regExp.Match(strName).Groups

        ' Last name
        MsgBox(matchGroups(1).Value)
        ' First name
        MsgBox(matchGroups(2).Value)
        ' Middle initial (If any)
        MsgBox(matchGroups(3).Value)
    End Sub

'******** OR.....

   'strName =  "Last First MI"
    Private Function UpperToLower(ByVal strName As String)
        Dim regExp As New Regex("([a-zA-Z]{1,})\s{1}\s{0,}([a-zA-Z]{1,})\s{0,}([a-zA-Z]{0,})")
        Dim matchGroups As GroupCollection = regExp.Match(strName).Groups
        Dim str As String

        ' Last name
        str = (UCase(matchGroups(1).Value.Substring(0, 1)) & LCase(matchGroups(1).Value.Substring(1)) & " ")
        ' First name
        str += (UCase(matchGroups(2).Value.Substring(0, 1)) & LCase(matchGroups(2).Value.Substring(1)) & " ")
        ' Middle initial (If any)
        str += (UCase(matchGroups(3).Value))
        Return str

        'OR YOU CAN USE
        'Dim myTI As TextInfo = New CultureInfo("en-US", False).TextInfo
        'Return myTI.ToTitleCase(strName)

    End Function