hanishgautam
07-08-2013, 09:17 PM
This the code by which you are able to reverse a string by using array method
Sub Reverse_String_Using_Array()
Dim strString As String
Dim lngCount As Long
Dim strReverse As String
Dim Arr()
strString = Application.InputBox("Enter your string which you want to reverse")
For lngCount = 1 To VBA.Len(strString)
ReDim Preserve Arr(lngCount)
Arr(lngCount) = VBA.Mid(strString, lngCount, 1)
Next lngCount
For lngCount = UBound(Arr) To LBound(Arr) Step -1
strReverse = strReverse & Arr(lngCount)
Next lngCount
MsgBox strReverse
Erase Arr
End Sub
Sub Reverse_String_Using_Array()
Dim strString As String
Dim lngCount As Long
Dim strReverse As String
Dim Arr()
strString = Application.InputBox("Enter your string which you want to reverse")
For lngCount = 1 To VBA.Len(strString)
ReDim Preserve Arr(lngCount)
Arr(lngCount) = VBA.Mid(strString, lngCount, 1)
Next lngCount
For lngCount = UBound(Arr) To LBound(Arr) Step -1
strReverse = strReverse & Arr(lngCount)
Next lngCount
MsgBox strReverse
Erase Arr
End Sub