ExtractFirstAndLastName – Extracting the first/last name from a string will the full name

ExtractFirstAndLastName – Extracting the first/last name from a string will the full name

' Extract the first and last name from a string will the full name.' The routine handles the "LastName, FirstName" and "FirstName LastName" ' formats, and returns the first and last name with byref output parameters.'' Example:'    Dim firstName, lastName As String'    ExtractFirstAndLastName("Marco", firstName, lastName)'    Debug.WriteLine("FirstName=" & firstName & " " & "LastName=" & lastName)'    ExtractFirstAndLastName("Marco Bellinaso", firstName, lastName)'    Debug.WriteLine("FirstName=" & firstName & " " & "LastName=" & lastName)'    ExtractFirstAndLastName("Bellinaso, Marco", firstName, lastName)'    Debug.WriteLine("FirstName=" & firstName & " " & "LastName=" & lastName)Sub ExtractFirstAndLastName(ByVal fullName As String, ByRef firstName As String, _    ByRef lastName As String)    firstName = ""    lastName = ""    ' if the fullname has a comma, it considers the     ' "LastName, FirstName" format, and     ' "FirstName LastName" otherwise    Dim commaPos As Integer = fullName.IndexOf(",")    If commaPos > -1 Then        lastName = fullName.Substring(0, commaPos).Trim()        firstName = fullName.Substring(commaPos + 1).Trim()    Else        ' find the space        Dim spacePos As Integer = fullName.IndexOf(" ")        ' if the space is not found, consider         ' everything as first name, otherwise do the split        If spacePos = -1 Then            firstName = fullName        Else            firstName = fullName.Substring(0, spacePos).Trim()            lastName = fullName.Substring(spacePos).Trim()        End If    End IfEnd Sub

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several