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

I worte a code for Palindrom and i am receiving error message could someone tell me where is the mistake is?

Could you please tell, what error message you get?

When you post your questions here, always include any error messages and/or describe the actual problem as detail as possible. Everyone's willing to help to solve your problem, but nobody has the time to figure out what is the problem. Thank you :)

And after fixing your code you could also try this

Try
  If Strings.StrReverse(wordTextBox.Text) = wordTextBox.Text 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
Catch ex As Exception
  MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.