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?

Recommended Answers

All 2 Replies

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

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

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.