Reverses the order of words in a string.
Reverses the order of words in a string.
Rate Reverses the order of words in a string.
(1(1 Vote))
Dim n As Long, Character As String, ReversedOrder As String, temp As String
n = Len(StringToUse)
Do
'select a character only if n > 1 or Mid() wont work
If n <> 0 Then
Character = Mid(StringToUse, n, 1)
End If
If Character = " " Or n = 0 Then
'if the selected character is space then reverse the contents of the temp string
'since we have part of the original string backwards
temp = StrReverse(temp)
'put the the reversed string fragment into the return string
ReversedOrder = ReversedOrder & " " & temp
'clear the temporary storage area so that another word can be stored
temp = ""
Else
' if the character selected was not a space then store it
temp = temp & Character
End If
n = n - 1
Loop While n > -1
'here the LTrim removes the leading space that is introduced the first
'time the loop runs
ReverseWordOrder = LTrim(ReversedOrder)
End Function
Reverses the order of words in a string. Comments
No comments yet — be the first to post one!
Post a Comment