03:02
0
If This is a question which you always been asked to answer, then here is a solution for the same.


  • StrReverse -Function is used to reverse a string which is given in brackets(Expression).The reversed String can be stored in another variable as the we did below.

Dim Strname, StrReversedName
StrName="VBmasters"
StrReversedName=StrReverse(StrName)
Msgbox StrReversedName

But the Question  here is without using the same you will have to reverse a given string.

Solution:-

  • When you have a variable which is been assigned to a given expression, you will have to take this as an input for your solution.
  • By taking the characters from the last position of the string and store the same to another variable inside the loop would lead us in accomplishing it.
  • To do the above one you have to use the VBA string Method Named "MID"Click here to know more about "MID".
    • Step 1:- Take the String len of the expression being reversed
      • Dim Strname,StrReversedName, StrLength
      • StrName="VBMasters"
      • StrLength=len(StrName)
    • Step 2:- Create a For loop which should be in decremental order.
      • For VariableI=StrLength to 1 Step-1
    • Step 3:-Take each char and Store the values to a separate string as follows by using Mid Function
      • StrReversedName=StrReversedName&mid(StrName, StrLength,1)
    • Step 4:- When the iteration completes you can use StrReversedName to print the reversed string which is reversed without using Strreverse function.
Script is,

  • Dim Strname,StrReversedName, StrLength
  • StrName="VBMasters"
  • StrReversedName=""
  • StrLength=len(StrName)
  • For VariableI=StrLength to 1 Step-1
  • StrReversedName=StrReversedName&mid(StrName, StrLength,1)
  • Next
  • msgbox StrReversedName



Thank You,
MastersAutomation Team





Newer Post
Previous
This is the last post.

0 comments:

Post a Comment