Reversing a String
This tip demonstrates how to reverse the position of the characters in a
string. For example, the string "String" will be converted to
"gnirtS".
Function Code
Public Function reversestring(revstr As String) As
String
' revstr: String to reverse
' Returns: The reverse string
Dim doreverse As Long
reversestring = ""
For doreverse = Len(revstr) To 1 Step -1
reversestring = reversestring & Mid$(revstr, doreverse, 1)
Next
End Function
Use
Dim strResult As String
strResult = reversestring("String")
MsgBox strResult
|