Resources » Code Snippets » String Manipulations

Palindrome


Posted Date: 25-Oct-2009  Last Updated:   Category: String Manipulations    
Author: Member Level: Gold    Points: 3



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)
Next

intJ = strAry.Length - 1
For intI = 0 To strAry.Length - 1
If intI > intJ Then
MessageBox.Show("Palindrome")
Exit Sub
End If
If strAry(intI) = strAry(intJ) Then
intJ = intJ - 1
Else
Exit For
End If
Next
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.


Did you like this resource? Share it with your friends and show your love!

Responses to "Palindrome"

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

Feedbacks      

Post 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:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Priya jain
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India