hi all..

how i can check there are palindrome in textbox.
e.g : i input "daniweb a bewinad"

thanks and please help.

Recommended Answers

All 7 Replies

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.

This is the code I am using for my palindrome problem but i will not correctly identify palindromes. Does anyone see any problems.

Dim numchar As Integer 'number of chars in phrase
Dim I As Integer 'lcv
Dim ch As Char 'one character in phrase
Dim intchar As Integer 'asc conversion
Dim TempWord As String 'word used while checking going forward

TempWord = ""
strstripped = ""

'trim
strphrase = Trim(strphrase)
numchar = Len(strphrase)

'keep only letters
For I = 1 To numchar
ch = Mid(strphrase, I, 1)
If (Asc(ch) >= 65 And (Asc(ch) <= 90)) Then
TempWord += ch
strstripped = strstripped & ch
numchar = numchar - 1
End If
Next I

strphrase = TempWord

commented: :) +0

See if this help :

Dim strTEXT As String
Dim intSTR_LEN As Integer
Dim intCOUNT As Integer
Dim boolPALIN As Boolean

Private Sub Command1_Click()
strTEXT = Text1
boolPALIN = True

strTEXT = Replace(strTEXT, ",", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, ".", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, "'", "", , , vbTextCompare)
strTEXT = Replace(strTEXT, " ", "", , , vbTextCompare)

intSTR_LEN = Len(strTEXT)

If Int(intSTR_LEN / 2) = intSTR_LEN Then
    For intCOUNT = 1 To intSTR_LEN / 2
        If Mid(strTEXT, intCOUNT, 1) <> Mid(strTEXT, intSTR_LEN - (intCOUNT - 1), 1) Then boolPALIN = False
    Next intCOUNT
Else
    For intCOUNT = 1 To (intSTR_LEN / 2) - 1 
        If Mid(strTEXT, intCOUNT, 1) <> Mid(strTEXT, intSTR_LEN - (intCOUNT - 1), 1) Then boolPALIN = False
    Next intCOUNT
End If
If boolPALIN = True Then MsgBox ("The phrase '" & strTEXT & "' is a palindrome!") Else MsgBox ("The phrase '" & strTEXT & "' is NOT palindrome!")
End Sub

try this

dim my_string as string

my_string = "your string goes here..."

if my_string = StrReverse(my_string) then
MsgBox ("This is palindrome!")
end if

thanks all :)

you're welcome :)

yeah,,i hope you all can see if my make a new thread too..
once again thanks a million :D

yeah,,i hope you all can see if my make a new thread too..
once again thanks a million :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.