|
-
Sep 27th, 2000, 10:45 AM
#1
Thread Starter
Junior Member
I have to write a simple program that checks for a palindrome(a word or sentence that reads the same from right to left and left to right...eye, eve). I have to enter a palindrome sentence into a text box it will check and see if it is a palindrome usind the whil loop statement. Punctuation must also be included. A form is also needed.
-
Sep 27th, 2000, 10:46 AM
#2
Lively Member
-
Sep 27th, 2000, 11:05 AM
#3
There you go. It doesn't use a loop, but it works.
Code:
If txtInput.Text = StrReverse(txtInput.Text) Then
'The string is a palindrome.
End If
Is it a school assignment?
-
Sep 27th, 2000, 11:13 AM
#4
There is a way WITH a while loop:
Code:
Dim intPosition As Integer
Dim strText As String
Dim strResult As String
strText = txtInput.Text
While intPosition =< Len(strText)
intPosition = intPosition + 1
strResult = Mid(strText, intPosition, 1) & strResult
Wend
If strResult = strText Then
MsgBox "The string is a palindrome!"
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|