943,704 Members | Top Members by Rank

Ad:
Mar 3rd, 2008
0

vb6 palindrome

Expand Post »
hey
I am trying to make a program on visual basic 6 to determine weather a
word or phrase is a palindrome or not. I need my program to be able to
tell if the word or phrase is a palindrome and it not being case
sensitive. The code below words to a certin point then brings up an
error but i have no clue why it wont work any help will be appreciated.
Thanks

I know some things that need to be inculued : arrays and fixed loops and it also needs to take out white spaces.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sofian786 is offline Offline
5 posts
since Feb 2008
Mar 3rd, 2008
3

Re: vb6 palindrome

see this palindrome program :

Palindrome.zip

don't forget to give feedback.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,138 posts
since Nov 2007
Apr 5th, 2009
-1

Re: vb6 palindrome

Thanks a lot !
Reputation Points: 8
Solved Threads: 0
Newbie Poster
stevebush is offline Offline
9 posts
since Apr 2009
Apr 5th, 2009
0

Re: vb6 palindrome

Dim le
Dim mide
Dim i
Private Sub Command1_Click()
i = 0
Dim yes As Boolean

le = Len(Text1.Text) + 1

Do While i < Len(Text1.Text) - 1
i = i + 1
mide = mid(Text1.Text, i, 1) 'take the next 1 letter in text1.text from position i

If Not mide = mid(Text1.Text, le - i, 1) Then 'if its not the same as the leter i positon from the back then
yes = True
End If
Loop


If yes = False Then
MsgBox "Pal"
Else
MsgBox "Not"
End If

End Sub
Reputation Points: 8
Solved Threads: 3
Junior Poster in Training
crackerjacker is offline Offline
53 posts
since Sep 2008
Apr 6th, 2009
0

Re: vb6 palindrome

Or... use the strReverse command

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub PalindromeTest(ByVal sWord As String)
  2. Dim sReversedWord As String
  3.  
  4. sReversedWord = StrReverse(sWord)
  5.  
  6. If StrComp(sWord, sReversedWord, vbTextCompare) = 0 Then
  7. MsgBox "Palindrome!"
  8. Else
  9. MsgBox "Not a Palindrome!"
  10. End If
  11. End Sub

You could change that to a function and return a boolean value instead of message boxes if you preferred.

Note: Just read the OP again and saw he needs it to use arrays and fixed loops which my example doesn't use. Oh well, I'll post it anyway for reference

Edit: sucked into an old thread again... fail
Last edited by jonifen; Apr 6th, 2009 at 5:15 pm. Reason: Sucked in again :/
Reputation Points: 13
Solved Threads: 17
Junior Poster
jonifen is offline Offline
152 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Windows email and vb6
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Help with Shell or any other simmilar function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC