Code.GeekInterview.com
 
Code Samples VB.NET
 

Split Name to First and last Name


Code ResourceAuthor: Lokesh  

Difficulty Level:

Published: 6th Feb 2007   Read: 9186 times  

Filed in: VB.NET
Add Comment


 

 

Sponsored Links


 

 

Split Name to First and last Name. Public Function Sample() MsgBox getFirst_Name("LOKESH MURTHY") MsgBox getLast_Name("LOKESH MURTHY") End Function.

 


Sample Code
  1.  
  2. Public Function getFirst_Name(Full_Name As String)
  3. On Error Resume Next
  4.    If IsNull(Full_Name) = True Or Len(Trim(Full_Name)) = 0 Then
  5.         getFirst_Name = " "
  6.    End If
  7.    Dim I As Long
  8.    For I = Len(Full_Name) To 1 Step -1
  9.        If Mid(Full_Name, I, 1) = " " Then
  10.            getFirst_Name = Mid(Full_Name, 1, I)
  11.            Exit Function
  12.        End If
  13.    Next I
  14. End Function
  15. Public Function getLast_Name(Full_Name As String)
  16. On Error Resume Next
  17.    If IsNull(Full_Name) = True Or Len(Trim(Full_Name)) = 0 Then
  18.         getLast_Name = " "
  19.    End If
  20.    Dim I As Long
  21.    For I = Len(Full_Name) To 1 Step -1
  22.        If Mid(Full_Name, I, 1) = " " Then
  23.            getLast_Name = Trim(Mid(Full_Name, I, 999))
  24.            Exit Function
  25.        End If
  26.    Next I
  27. End Function
  28.  
Copyright GeekInterview.com


Next Article: Sample Cart


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

good code
Comment posted by: bhanudas on 2007-11-19T13:23:26

Popular Coders

# Coder NameHits
1. Lokesh9187
2. supersubra5459
3. jsubha20095264
4. Lokesh M4278
5. sureshrndsoft3180
6. Biswabed Dash2260
7. alaa_eng1646

Active Coders

# Coder NameCodes
1. supersubra1
2. Biswabed Dash1
3. Lokesh1
4. Lokesh M1
5. jsubha20091
6. sureshrndsoft1
7. alaa_eng1

Refined Tags