Reversing order

ksgush

New member
Joined
Oct 17, 2005
Messages
2
Programming Experience
Beginner
I am wondering if someone could help me with this reverse order problem I am having. I am trying to take a string and output it in reverse order.. like.....

Kyle, Gush ......... reverse order output: hsuG ,elyK

Here is what I have so far, but something isn't working right, could someone help ?



strNEWINDEX = strFLNAME.Length
DoWhile strNEWINDEX <> 0
strFLNAME =
Me.txtFLNAME.Text.ToUpper
strMinusone = strNEWINDEX + 1
strChar = strFLNAME.Substring(strMinusone, strNEWINDEX)
strReverse =
Me.lblReverse.Text
Me.lblReverse.Text = strReverse & strChar
strNEWINDEX = strNEWINDEX + 1
Loop

Thanks, Kyle
 
actually i would build a new string by going through the source string backwards:

VB.NET:
Private Function Reverse(Byval Source As String) As String
  Dim OutPut As String
  For intCounter As Integer = Source.Length To 1 Step -1
    OutPut &= Mid(Source, intCounter, 1)
  Next intCounter
  Return OutPut
End Function

i'm pretty sure that's 100% correct, i dont have the IDE with me right now so that code came 100% from memory but you get the idea

also i made it a function so you simply call like like you would anyother sub or function too
 

Latest posts

Back
Top