[Last Call] Learn how to a build a cloud-first strategyRegister Now


Reverse a string??

Posted on 2004-11-07
Medium Priority
Last Modified: 2010-04-24
I have the following string:

John Doe

I want it to look like this:

Doe, John
Question by:Richard Kreidl
1 Comment
LVL 43

Accepted Solution

TimCottee earned 1000 total points
ID: 12518424
Hi rkckjk,

Dim aryBits() As String
aryBits = Split(SourceString," ")
Dim strResultString As String
Dim intBit As Integer
For intBit = aryBits.GetUpperBound(0) To aryBits.GetLowerBound(0) Step -1
  strResultString = strResultString & aryBits(intBit) & Iif( intBit = aryBits.GetUpperBound(0),", "," ")
Msgbox strResultString

This should do it, if there is more than one space, the comma will only be added after the first word.

Tim Cottee
Brainbench MVP for Visual Basic

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

831 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