Jul 5, 2012

VB Program - Palindrome or not

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim length, i As Integer
        Dim v1, v2 As String
        length = Len(TextBox1.Text)
        For i = 1 To length
            v1 = v1 + UCase(Mid(TextBox1.Text, i, 1))
        Next i
        For i = length To 1 Step -1
            v2 = v2 + UCase(Mid(TextBox1.Text, i, 1))
        Next i
        If v1 = v2 Then
            MsgBox("given word is palindrome")
        Else : MsgBox("given word is not palindrome ")
        End If
    End Sub
End Class



No comments:

Post a Comment