0 Shares 8509 Views 5 Comments

Reverse a string without using strReverse or Mid Function

Mar 13, 2013
8509 Views 5
Welcome to automated-360.com

Recently one of my colleagues put an interesting situation to script in vbs. It was to reverse a string without using Mid or string Reverse function. For example, if the given string is – AUTOMATED 360 , the result should be DETAMOTUA 063.

Since most of us are likely to use the built in functions and not to think about other ways of doing the same, it sounds like a bit tough. I also had the same situation, but a few minutes of analysis resulted me the solution for the same. The trick is to put all the characters in array and then print the array in reverse order.

below is the code using array to reverse the string.

Here is one more nice way to do this using array again.

You may be interested

UFT Patch Updates – UFT 14.03
Unified Functional Testing
1448 views1
Unified Functional Testing
1448 views1

UFT Patch Updates – UFT 14.03

Saket - Mar 11, 2018

Post the launch of UFT 14.0, there are three patch updates has been released including a number of features and enhancement. Recently Micro Focus unveiled third patch…

Setting up Web Service Automation Project
Katalon Studio
1305 views
Katalon Studio
1305 views

Setting up Web Service Automation Project

Saket - Oct 24, 2017

Web services are specific services that can be published and called over the Internet by client applications. Katalon Studio supports functional testing of web services. This topic…

Setting up Mobile Automation Project in MacOS
Katalon Studio
1081 views1
Katalon Studio
1081 views1

Setting up Mobile Automation Project in MacOS

Saket - Oct 09, 2017

Using Katalon Studio, mobile tester can design automation test for both Android and iOS to run on physical devices, cloud services and emulators. This tutorial explains how…

5 Comments

  1. Hello Saket,

    Nice code for reverse string, I have faced this question in most of interviews.

    Can I have function for generating the qtp results with screen shots in a PDF or word formate please?

    Thanks in advance.

    REgards,

    Sreekanth

    Reply
  2. srt = “Automation”

    For i = 1 To Len(srt)

    temp = temp & Left(Right(srt, i), 1)

    Next

    MsgBox temp

    Reply
  3. Sub abc()

    srt = “Automation is good”
    Count = Split(srt, ” “)
    ‘MsgBox UBound(Count)
    For a = 0 To UBound(Count)
    For i = 1 To Len(Count(a))
    temp1 = temp1 & Left(Right(Count(a), i), 1)

    Next

    temp2 = temp2 & ” ” & temp1

    temp1 = “”
    Next

    MsgBox temp2
    End Sub

    Reply

Leave a Comment

Your email address will not be published.

Most from this category

Join The Growing Group of 15000+ Test Automation Engineers

Signup for our newsletter and get access to free downloads, as well as tips, tricks and techniques and various test automation resources.
Name
Email Address
Secure and Spam free...