This function checks whether the given string is palindrome or not.

Private Sub Palindrome()
Dim strChar As String
Dim intI, intJ As Integer
Dim strAry(10) As String

strChar = "madam"
ReDim strAry(strChar.Length - 1)
For intI = 1 To strChar.Length
strAry(intI - 1) = Mid$(strChar, intI, 1)

intJ = strAry.Length - 1
For intI = 0 To strAry.Length - 1
If intI > intJ Then
Exit Sub
End If
If strAry(intI) = strAry(intJ) Then
intJ = intJ - 1
Exit For
End If
MessageBox.Show("Not Palindrome")
End Sub

In the above code,I have passed the string "madam" which is a palindrome.You may change it as per your requirement.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: