Reverse a string??

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

John Doe

I want it to look like this:

Doe, John
Question by:rkckjk
    1 Comment
    LVL 44

    Accepted Solution

    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

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now