| | |
Palindromes on visual basic 5.0
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Solved Threads: 0
Hiya
I am trying to make a program on visual basic 5.0 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.
I am trying to make a program on visual basic 5.0 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.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub cmdStart_Click() Dim inputWord As String Dim testWord As String Dim reverseWord As String Dim testChar As String Dim i as Integer Dim maxIndex as Integer 'Get input from the user. inputWord = InputBox("Please enter your word") 'Record the input in lower case and remove spaces (you can 'add checks for tabs, linefeeds, etc). maxIndex = Len(inputWord) - 1 For i = 0 To maxIndex testChar = Mid(inputWord, i, 1) If testChar <> " " Then testWord = testWord & LCase(testChar) End If Next 'Reverse testWord. maxIndex = Len(testWord) - 1 For i = maxIndex To 0 Step -1 reverseWord = reverseWord & Mid(testWord, i, 1) Next 'Compare reverseWord to testWord and output the results. If testWord = reverseWord Then MsgBox "Yes, it's a palindrome" Else MsgBox "No, it's not a palindrome" End If 'Get input from the user. inputWord = InputBox("Please enter your word") 'Record the input in lower case and remove spaces (you can 'add checks for tabs, linefeeds, etc). maxIndex = Len(inputWord) - 1 For i = 0 To maxIndex testChar = Mid(inputWord, i, 1) If testChar <> " " Then testWord = testWord & LCase(testChar) End If Next 'Reverse testWord. maxIndex = Len(testWord) - 1 For i = maxIndex To 0 Step -1 reverseWord = reverseWord & Mid(testWord, i, 1) Next 'Compare reverseWord to testWord and output the results. If testWord = reverseWord Then MsgBox "Yes, it's a palindrome" Else MsgBox "No, it's not a palindrome" End If End Sub
Hi,
u can simply use the "Reverse" function. I'am not sure if Reverse function is available in VB5 or not, but we have it in VB6. Check this :
u can simply use the "Reverse" function. I'am not sure if Reverse function is available in VB5 or not, but we have it in VB6. Check this :
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim sSQL As String sSQL=InputBox("Please enter your word") If Trim(sSQL) <> "" Then If sSQL = Reverse(sSQL) Then Msgbox "Palindrome True" Else Msgbox "Not A Palindrome" End If End If REgards Veena
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- Creating an OS in visual basic 6.0 (Visual Basic 4 / 5 / 6)
- The Move.....Visual Basic 6, Visual Basic .NET ? (VB.NET)
- Encrypting a Visual Basic application (Visual Basic 4 / 5 / 6)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
- Visual Basic.net (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: how to import a background music?
- Next Thread: how to delete msflexgrid rows which are empty
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





