Computer Science Canada

Palindrome program help anyone!!!!

Author:  zomg [ Thu Oct 21, 2004 12:04 pm ]
Post subject:  Palindrome program help anyone!!!!

Hi im new at VB and i having trouble with my palidrome project...

code:

Dim a As String
Dim b As String
Private Sub Form_Activate()
a = InputBox("enter something to look for palindrome")
b = StrReverse(a)
If a = b Then
MsgBox ("That is a palindrome!!!!")
Else
MsgBox ("No, i am sorry")
End If
End Sub


i want it so that the program doesnt look for punctuation or spaces

right now i can type " racecar" and it will work but not "race car" or
"race, car"

Author:  McKenzie [ Thu Oct 21, 2004 1:07 pm ]
Post subject: 

I would make a function that would take a string and return a string with all of the spaces and punctuation stripped out. Use the Mid function to go through the word one letter at a time.
<pseudocode>
code:
ans = ""
for i = 1 to length
     if Mid(word,i,1) >= "a" and Mid(word,i,1) <= "z"
         ans = ans + Mid(word,i,1)
     end if
next i

Author:  zomg [ Fri Oct 22, 2004 11:31 am ]
Post subject: 

thx so much

but where do i put that in the program? Embarassed

Author:  Tony [ Fri Oct 22, 2004 9:54 pm ]
Post subject: 

umm.. processing the input right after you get the value from user would just make sence Very Happy

Author:  donz [ Wed Jan 05, 2005 1:23 am ]
Post subject:  Palindrome program

can anyone here help me to look for a palindrome program... pls i need it badly.... Crying or Very sad


: