Skip to content

Reversing a String in VB.net

The following code snippet shows how easy it is to reverse a string in Vb.net:

Dim originalString As String = "Some text here"
Dim reversedString As String = originalString.Reverse.ToArray
'reversedString now equals "ereh txet emoS"

As you can see, this is very easy to do, however, most of the examples I found online were overly complicated. So, I thought I’d post my nice easy way.  Happy coding!

1 thought on “Reversing a String in VB.net”

  1. Thanks you so right, the other code is fancy and all but yours is great. I modified it to read from and right to the same text box

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    ‘Chucks the entered word into the textbox1.text
    Dim mystring As String = TextBox1.Text
    ‘reversedString is a temp array that Reverses the entered string and stores it
    Dim reversedString As String = mystring.Reverse.ToArray
    ‘writes into the textbox the string
    TextBox1.Text = mystring.Reverse.ToArray
    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *