How to reverse a string using VBScript

Send Us a Sign! (Contact Us!)
Word PDF Epub Text
XML XPS
str="uday"

For i=len(str) to 1 step -1
strchar=mid(str,i,1)
resultstr=resultstr&strchar
Next
msgbox resultstr

...or you can use the built-in function in VBScript:

msgbox strreverse("uday")

Alternate Method

Here is how we can Reverse a String without using any functions like len & mid:

Option Explicit

Dim yourstr,r,letter,result,s
yourstr="program"
Set r=new regexp
r.pattern="[a-z A-Z]"
r.global=true
set s=r.execute(yourstr)
For each letter in s
result= letter.value&result
Next
msgbox(result)

SOURCE

LINK

LANGUAGE
ENGLISH

1 thought on “How to reverse a string using VBScript”

Comments are closed.