I am working on a this programming project for class using Visual Basic 2010. I tryed coding it with the code bellow and it doesnt work. Could someone please help me with it. Thanks!
This is the question:
Write a program that allows the user to input a word or phrase and then determine if it is a palindrome. The program should use a Boolean-valued Function procedure named IsPalindrome that returns the value True when the word or phrase is a palindrome and the value False otherwise.
Your program should also include the following:
• Sub Procedure for Getting the input
• Sub Procedure for Validating the input
• Sub Procedure for Displaying the output
• Proper internal documentation
• Complete External Documentation (Method of choice for describing the Solution)
This is the code I have got so far:
Private Sub btnCheck_Click(sender As System.Object, e As System.EventArgs) Handles btnCheck.Click
Dim strword As String
Dim intindex As Integer
Dim strarr() As String
If Not IsGoodInput(strword) Then
Exit Sub
End If
ReDim Preserve strarr(intindex)
strarr(intindex) = strword.Trim
intindex += 1
txtPhrase.Text += " " + strword
txtPhrase.Text = txtPhrase.Text.Trim
If IsPalindrome() Then
MessageBox.Show("You entered a Palindrome")
End If
End Sub
Private Function IsGoodInput(ByRef word As String) As Boolean
If IsNumeric(txtWord.Text) Or (txtWord.Text) = "" Then
MsgBox("Please enter a word.", , "Input Error")
txtWord.Focus()
Return False
Else
word = txtWord.Text
Return True
End If
End Function
Private Function IsPalindrome() As Boolean
Dim strarr() As String
Dim intupper = strarr.GetUpperBound(0)
Dim bPalindrome As Boolean = True
For i As Integer = 0 To CInt(intupper / 2)
bPalindrome = strarr(i) = strarr(intupper - i)
If Not bPalindrome Then txtYesOrNo.Text = " No it is not a Palindrome" : Return False
Next
txtYesOrNo.Text = " Yes it is Palindrome"
Return True
End Function