Function CheckPalindrom2StringFunction()
MyStr=Ucase(inputbox("Enter the String:"))
RevStr=strreverse(MyStr)
if strcomp(MyStr,RevStr)=0 then
msgbox "It is a Palindrome"
else
msgbox "It is not a Palindrome"
end if
End Function
Function CheckPalindromeString()
Word = Ucase(inputbox("Enter the String:"))
length = Len(Word)
For i = 1 To length
Str1 = Str1 + Mid(Word, i, 1)
Next
For i = length To 1 Step -1
Str2 = Str2 + Mid(Word, i, 1)
Next
If Str1 = Str2 Then
MsgBox "given word is palindrome"
Else
MsgBox "given word is not palindrome "
End If
End Function
Function CheckPalindromeInt()
n = InputBox(" Enter a number=")
temp = n
rev = 0
Do While temp > 0
r = temp Mod 10
rev = rev * 10 + r
temp = Int(temp / 10)
Loop
If Int(n) = rev Then
MsgBox "The palindrom number is=" & rev
Else
MsgBox "Please enter correct palindrom number"
End If
End Function
2 comments:
how does this works "1 Step -1" ... what function does it do
Hi Narayanan,
1 Step -1 is the reverse loop start from max length to 0.
Thanks
Neeraj
Post a Comment