I worte a code for Palindrom and i am receiving error message could someone tell me where is the mistake is?
thank you.
Dim i As Integer
Dim word As String = wordTextBox.Text
Dim testWord As String
Dim reverseWord As String
Dim testChar As String
Dim maxIndex As Integer
maxIndex = Len(word) - 1
For i = 0 To maxIndex
testChar = Mid(word, i, 1)
If testChar <> " " Then
testWord = testWord & LCase(testChar)
End If
Next i
maxIndex = Len(testWord) - 1
For i = maxIndex To 0 Step -1
reverseWord = reverseWord & Mid(testWord, i, 1)
Next
If testWord = reverseWord Then
MessageBox.Show("The word is palindrome", "Palindrom", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("The word is not Palindrome.", "Palindrom", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
wordTextBox.SelectAll()
End Sub