String reverse in VBScript without using inbuilt function

String reverse in VBScript is a very common task. If you need to reverse a string in VBScript without using inbuilt reverse functions, we can use mid function to get the characters one by one and concat them using a for loop in the iterator decrement direction.

Example code: String reverse in VBScript without using inbuilt function
Function reverseString(strInputString)

  Dim oStr
  Dim oLength
  Dim oChar
  Dim iCounter  
  nLength=len(strInputString)

  For iCounter=nLength to 1 step-1
        oChar=oChar & mid(strInputString,iCounter,1)
  Next
  reverseString= oChar
  
End Function

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.