Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 5
Reputation: sofian786 is an unknown quantity at this point 
Solved Threads: 0
sofian786 sofian786 is offline Offline
Newbie Poster

vb6 palindrome

 
0
  #1
Mar 3rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: vb6 palindrome

 
3
  #2
Mar 3rd, 2008
see this palindrome program :

Palindrome.zip

don't forget to give feedback.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 7
Reputation: stevebush is an unknown quantity at this point 
Solved Threads: 0
stevebush's Avatar
stevebush stevebush is offline Offline
Newbie Poster

Re: vb6 palindrome

 
-1
  #3
Apr 5th, 2009
Thanks a lot !
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 34
Reputation: crackerjacker is an unknown quantity at this point 
Solved Threads: 2
crackerjacker crackerjacker is offline Offline
Light Poster

Re: vb6 palindrome

 
-1
  #4
Apr 5th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 140
Reputation: jonifen is an unknown quantity at this point 
Solved Threads: 15
jonifen jonifen is offline Offline
Junior Poster

Re: vb6 palindrome

 
0
  #5
Apr 6th, 2009
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 :/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC