IT KNOWLEDGE

IT KNOWLEDGE
BC

Thursday, May 22, 2014

How to Reverse a String (VB.Net)

In this sample, I will show you how to reverse character in word or sentence. I use 2 TextBox and 1 Button as below:

No Control Type Name Text
1 Textbox1 TextBoxBase
2 Textbox2 TextBoxReverse
3 Button1 ButtonReverse Reverse


Code
Public Class ReverseString
    Dim textToReverse As String
    Dim Letters() As Char
    Private Sub ButtonRevers_Click(sender As Object, e As EventArgs) Handles ButtonRevers.Click
        textToReverse = TextBoxBase.Text
        Letters = textToReverse.ToCharArray()
        Array.Reverse(Letters)
        Dim ReversedText As New String(Letters, 0, Letters.Length)
        TextBoxReverse.Text = ReversedText
    End Sub
End Class

Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: itech-9999

0 comments: