It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Palindromes in visual basic 5.0

Moderator: dafunkymunky

Palindromes in visual basic 5.0

Postby xlilxmizzxinnocentx on Tue Jul 31, 2007 11:21 pm

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.

Dim i As Long
Dim lngLeft As Long
Dim lngRight As Long

pstrText = LCase$(pstrText)
lngLeft = 1
lngRight = Len(pstrText)
IsPalindrome = True
Do While lngLeft < lngRight
' Get left character
Do While lngLeft < lngRight
Select Case Asc(Mid$(pstrText, lngLeft, 1))
Case 97 To 122: Exit Do
End Select
lngLeft = lngLeft + 1
Loop
' Get right character
Do While lngRight > lngLeft
Select Case Asc(Mid$(pstrText, lngRight, 1))
Case 97 To 122: Exit Do
End Select
lngRight = lngRight - 1
Loop
If Mid$(pstrText, lngLeft, 1) <> Mid$(pstrText, lngRight, 1) Then
IsPalindrome = False
Exit Do
End If
lngLeft = lngLeft + 1
lngRight = lngRight - 1
Loop
End Function
xlilxmizzxinnocentx
 
Posts: 0
Joined: Tue Jul 31, 2007 11:15 pm
Location: Stirling

Who is online

Users browsing this forum: No registered users and 1 guest