Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples VB.NET
 

Split Name to First and last Name


Code ResourceAuthor: Lokesh  

Difficulty Level:

Published: 6th Feb 2007   Read: 5942 times  

Filed in: VB.NET
Add Comment


 


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 Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Comments

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

Popular Coders

# Coder NameHits
1. Lokesh5943
2. supersubra2506
3. Lokesh M1558
4. Biswabed Dash828

Active Coders

# Coder NameCodes
1. supersubra1
2. Biswabed Dash1
3. Lokesh1
4. Lokesh M1

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape