C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Palindrome Word


Posted Date: 28 Aug 2008    Resource Type: Code Snippets    Category: VB.NET Syntax

Posted By: Ritesh N. Jain       Member Level: Gold
Rating:     Points: 7



Palindrome word can be defined as string that have same meaning when read from Left-Right or Right-Left.Below function can check if given word is Palindrome or not.

In below code one can also learn how to use Recursive function.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strInput as string = "racecar"

If IsPalinDrome(0, strInput.Length - 1, strInput) Then
Messagebox.show(strInput & " is Palindrome")
Else
Messagebox.Show(strInput & " is Non Palindrome")
End if

End Sub

'Below is Recursive function that varifies if word is Palindrome or not
Private Function IsPalinDrome(ByVal intStart As Integer, ByVal intEnd As Integer, ByVal strWord As String) As Boolean
Try
'This is Termination condition for Palindrome string
If intStart > intEnd Then
Return True
End If
'This is Termination condition for Non-Palindrome string
'If Mirror character do not match breack the Recursive function
If strWord.Chars(intStart) <> strWord.Chars(intEnd) Then
Return False
End If
'If Mirror Character matches,continue with Recursive function
If strWord.Chars(intStart) = strWord.Chars(intEnd) Then
Return IsPalinDrome(intStart + 1, intEnd - 1, strWord)
End If

Catch exc As Exception
Throw exc
End Try

End Function




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Palindrome recursive  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Degrees to Radians
Previous Resource: System Tray icon
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference call

Contact Us    Privacy Policy    Terms Of Use