Solved

String manipulation

Posted on 2004-03-23
2
257 Views
Last Modified: 2010-05-01
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
Comment
Question by:cakirfatih
2 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10662731
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
 
LVL 5

Accepted Solution

by:
waelothman earned 50 total points
ID: 10662776
MyString=Split(Name,",")

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now