21 Program to print reverse of string and check whether input string is palindrome or not in VB.NET

Code:

Public Class Form1

    Dim str1, str2, temp As String

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        str1 = TextBox1.Text
    End Sub

    Public Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        str2 = StrReverse(str1)
        TextBox2.Text = str2
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        TextBox2_TextChanged(sender, e)
        If str2 = str1 Then
            MsgBox(" Given string is Palindrome ")
        Else
            MsgBox(" Given string is Not Palindrome ")
        End If
    End Sub


End Class


Output:  



Previous
Next Post »