reverse a string

Posted on 2005-05-13
Last Modified: 2008-03-03

Is there any way to reverse a string similar to this "2000 2001 2004  " so it looks like "2004 2001 2000".

I have tried StrReverse (strYears) without any success.

Some important things to note:

1) The number of years may vary in a string
2) There will always be an undetermined number of spaces at the end of the string
3) I'm using Access 2000

Any help would be appreciated.

Question by:JakeB52
    LVL 13

    Expert Comment

    dim sList$()
    dim iCounter%
    dim sDone$
    sList = Split(sInput, " ")
    for iCounter = ubound(sList) to lbound(sList) step -1
      sDone = sDone & " " & sList(iCounter)
    sDone = Trim(sDone)

    Done :)
    LVL 13

    Accepted Solution

    oh, ok for your point 2, you might use instead:
    sList = Split(trim(sInput), " ")

    Do you need the spaces at the end of the resulting string as well? (probably not?)

    Expert Comment

    Use this new function StrReverse().

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now