Write code for palindrome?

Answer Posted / sayan

Private Sub btnAnswer_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnevaluate.Click
Dim Input As String

If IsPalindrome(Input) Then
txtAnswer.Text = "True"
Else
txtAnswer.Text = "False"

End If



End Sub
Function IsPalindrome(ByVal Input As String) As Boolean

Dim Front As Integer
Dim Back As Integer
Dim Middle As Integer
Dim nPalindrome As Boolean

IsPalindrome = False
nPalindrome = True


Back = Input
Middle = Back / 2
Front = 1
If (Back < 1) Then
Exit Function
End If

Do While (Front <> Back And Front <= Middle)
If (Mid(Input, Front, 1) <> Mid(Input, Back, 1)) Then
nPalindrome = False
Exit Do
End If
Back = Back - 1
Front = Front + 1
Loop
IsPalindrome = nPalindrome
Exit Function

End Function
End Class

Is This Answer Correct ?    7 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is int32 in c#?

506


Why do we use classes?

504


Can you declare a field readonly?

542


Explain About delegates

598


What do u mean by delegation?

541






What is streamreader/streamwriter class?

518


How do I create a multilanguage, single-file assembly?

499


Why main method is static in c#?

498


I wish to create a windows application to perform a similar function as that of the "Search" which is provided to look for related files and folders in the System.. What steps must i follow??

1534


How do you prevent a method from being overridden in c#?

460


Give some examples for built in datatypes in c#?

552


What is the use of delegate?

529


What does using do in c#?

517


If you want to convert a base type to a derived type, what type of conversion do you use?

487


What is the use of functional interface?

482