Custom Search

Friday, March 30, 2012

How to reverse the string with out using strreverse function and not rotate the loop up to string length? ex: if you have a string length 10 characters, string should be reversed in off of the loop rotation.

 str=inputbox ("Enter String:")
 intlen=round(len(str)/2)
 leftstr=mid(str,1,intlen)
 rgtstr=mid(str,intlen+1,len(str))
 res=mid(str,intlen,1)
 For i=1 to len(leftstr) -1

  leftres=mid(rgtstr,i,1)
  rgtres=mid(leftstr,intlen-i,1)
  res=leftres&res&rgtres

 Next

 If Len(str)<>len(res) Then
  res=mid(str,len(str),1)&res
 End If
 msgbox res

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.