Thursday, August 16, 2007
A function to reverse a string
Very simple, uses the VBA function StrReverse to reverse the input string.
'A function to reverse a string provided as input
'For example, the string "abcd" will become "dcba"
'Uses the VBA function StrReverse
Public Function ReverseString(sInputString As String) As String
On Error GoTo ReverseString_Error
ReverseString = StrReverse(sInputString)
Exit Function
ReverseString_Error:
ReverseString = "#ERROR#"
End Function
'For example, the string "abcd" will become "dcba"
'Uses the VBA function StrReverse
Public Function ReverseString(sInputString As String) As String
On Error GoTo ReverseString_Error
ReverseString = StrReverse(sInputString)
Exit Function
ReverseString_Error:
ReverseString = "#ERROR#"
End Function
Labels: String Operations