This VB Script demonstrates how we can reverse a string or a number given by the user and print it in a reverse order. Here we use Len and Mid methods of VB Script library. In the method one we will find the length of the string and store in y variable and then use a for loop in a descending order and give step as -1.
Method 1
MyStr = InputBox(“Enter a string to be reversed”)
y = Len(MyStr)
For x = y To 1 Step -1
aaachar = Mid(MyStr,x,1)
aaaNewStr = NewStr & char
Next
aaamsgbox newstr
Method 2 using the StrReverse Method.
No comments:
Post a Comment