Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Palindrome program help anyone!!!!
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zomg




PostPosted: 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"
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Thu Oct 21, 2004 1:07 pm   Post subject: (No 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
zomg




PostPosted: Fri Oct 22, 2004 11:31 am   Post subject: (No subject)

thx so much

but where do i put that in the program? Embarassed
Tony




PostPosted: Fri Oct 22, 2004 9:54 pm   Post subject: (No subject)

umm.. processing the input right after you get the value from user would just make sence Very Happy
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
donz




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: