• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

String manipulation

hello yall ,
This is really easy.
I have a string that looks like this "ABCDEFG.., ZYPYOYO"
Basically "LastNames" "Comma" "FirstNames" and I would like to seperate the two.
Please provide me with a Function in Visual Basic that can do that.
Thanks in Advance
0
cakirfatih
Asked:
cakirfatih
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
There are many ways to do this.  Here is one:

Private Sub Form_Load()
    Dim name As String
    Dim LastName As String
    Dim FirstName As String

    name = "ABCDEFG.., ZYPYOYO"
    LastName = Trim(Left(name, InStr(name, ",") - 1))
    FirstName = Trim(Mid(name, InStr(name, ",") + 1))
   
    Debug.Print name
    Debug.Print LastName
    Debug.Print FirstName
End Sub
0
 
waelothmanCommented:
MyString=Split(Name,",")

FirstName= Trim(MyString(0))
LastName= Trim(MyString(1))
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now