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

Discover more from Automation Script

Subscribe to get the latest posts sent to your email.

Related Posts