Reverse a String

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2006
Posts: 25
Reputation: hoosier23 is an unknown quantity at this point 
Solved Threads: 1
hoosier23 hoosier23 is offline Offline
Light Poster

Reverse a String

 
0
  #1
Apr 22nd, 2007
I'm having trouble reversing a string. Me thinks I've stared at this too long.

  1. Private Sub btnReverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReverse.Click
  2. Dim strOrgText As String
  3. Dim strRevText As String
  4. Dim array As Array
  5.  
  6. strOrgText = Me.txtTheString.Text
  7. array = strOrgText.ToCharArray()
  8.  
  9. strRevText = array.Reverse 'Here is my problem
  10.  
  11. strRevText = Me.lblResult.Text
  12.  
  13. End Sub

Thx
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Reverse a String

 
0
  #2
Apr 22nd, 2007
Try this:
  1. Dim input As String = "abc"
  2. Dim output As String = ""
  3. Dim CharStr As New Char
  4. For Each CharStr In input
  5. output = CharStr & output
  6. Next
  7. MessageBox.Show(output)
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 122
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Reverse a String

 
1
  #3
Apr 22nd, 2007
  1. strRevText = array.Reverse 'Here is my problem
thats becouse array.Reverse needs an argument and the other thing it does not produce value so you can't assign it to strRevText

  1. strRevText = Me.lblResult.Text
here is problem too , here u do not show the result !

after the correction this is ur code

Dim strOrgText As String
        Dim strRevText As [Char]()
        Dim array As Array

        strOrgText = Me.txtTheString.Text
        strRevText = strOrgText.ToCharArray
        array.Reverse(strRevText)   
        Me.lblResult.Text = strRevText

or u can use StrReverse function like this

  1. Me.lblResult.Text = StrReverse(Me.txtTheString.Text)
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 25
Reputation: hoosier23 is an unknown quantity at this point 
Solved Threads: 1
hoosier23 hoosier23 is offline Offline
Light Poster

Re: Reverse a String

 
0
  #4
Apr 23rd, 2007
Thanks Manal
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 11
Reputation: mhovidz is an unknown quantity at this point 
Solved Threads: 0
mhovidz's Avatar
mhovidz mhovidz is offline Offline
Newbie Poster

Re: Reverse a String

 
0
  #5
Apr 23rd, 2007
Good day!

Maybe this code will help you. Try this.

Dim StrongText as string
Dim ReverseText as string

StringText="This is a string"
ReverseText= StrReverse(StringText)

This will reverse the value of StringText variable.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC