Reverse String

This simple code reverses a string. (ie from 'hello' to 'olleh')

Function ReverseString(ByVal sText As String) As String

Dim lenText As Long, lPos As Long
 
  If Len(sText) = 0 Then Exit Function
 
  lenText = Len(sText)
  ReverseString = Space(lenText)
 
  For lPos = lenText To 1 Step -1
    Mid$(ReverseString, lenText - lPos + 1, 1) = Mid$(sText, lPos, 1)
  Next lPos
 
End Function

You might also like...

Comments

Agron Kovaci

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov