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
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
0 comments:
Post a Comment