Solved

String manipulation

Posted on 2004-03-23
2
256 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

13 Experts available now in Live!

Get 1:1 Help Now