0

i have to write a program for a palindrome on vb that uses a loop and a decision and i don't think i need any arrays or any other real big complications. this particular program when i tried it cause i cant actually use this one due to plagiarism didn't complete due to the number 1 being the wrong speed i guess i wasn't sure what it said. do you have any advise?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vb5prgrmr
0

The algorithm that checks if a string is palindrome is

Dim sInput As String
Dim i As Integer
Dim bIsPalindrome As Boolean


bIsPalindrome = True
For i = 1 To Len(sInput) / 2
    If Mid(sInput , i, 1) <> Mid(sInput,  Len(sInput ) - i + 1, 1) Then
        bIsPalindrome = False
        Exit For
    End If
Next

If bIsPalindrome Then
    'something to do if it's palindrom
Else: 'something if not

Cheers,
Ionut

0

Shame to have to use a loop because...

Private Function IsPalindrome(TheWord As String) As Boolean
If TheWord = strRev(TheWord) Then IsPalindrome = True
End Function

Good Luck

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.