Visual Basic 6 function "strrev"

Go back

Below you'll find the source for the Visual Basic 6 function strrev.

Attribute VB_Name = "modStrrev"
' This function is downloaded from:
' http://www.stefanthoolen.nl/archive/vb6-functions/
' 
' You may freely distribute this file but please leave all comments, including this one, in it.
' 
' @Author Stefan Thoolen <mail@stefanthoolen.nl>

Option Explicit

''
' Reverse a string
' Same syntax as the PHP function 'strrev'
' http://www.php.net/manual/en/function.strrev.php
' @param    String  tstr            The input string
' @return   String                  A reversed version
' @author   Stefan Thoolen <mail@stefanthoolen.nl>
Public Function strrev(tstr As String) As String
    Dim s As String, i As Integer
    For i = Len(tstr) To 1 Step -1
        s = s & Mid(tstr, i, 1)
    Next i
    strrev = s
End Function