.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

String Reverse without builtin functions

Posted By:Asha.MP       Posted Date: September 17, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

This code we can used to reverse the string without using builtin functions
 

 

Option Strict On

Option Explicit On

Public Class StrReverse

Shared Sub main()

Dim StrToRev As String = "Asha Usha MP"

Dim str As String = ""

Dim NoOfSpaces As Integer = 0

Dim ArrToStore(5) As String

For i = 0 To StrToRev.Length - 1

str += StrToRev(i)

If StrToRev(i) = " " Or StrToRev(i) = "" Then

ArrToStore(NoOfSpaces) = RevStr(str, str.Length - 2)

str = ""

NoOfSpaces += 1

End If

Next

ArrToStore(NoOfSpaces) = RevStr(str, str.Length - 1)

Dim revercedStr As String = ""

For i = 0 To NoOfSpaces

revercedStr = revercedStr + ArrToStore(i) + " "

Next

Console.WriteLine(revercedStr)

Console.ReadLine()

End Sub

Shared Function RevStr(ByVal SplitString As String, ByVal SpacePos As Integer) As String

Dim revString As String = ""

For i = 0 To SpacePos

revString += SplitString(SpacePos)

SpacePos -= 1

Next

Return revString

End Function

End Class



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend