'Program to check if the given string is a Palindrome or not 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 ifMore VB Scripts here.
Monday, March 14, 2011
VBScript code to check if a string is Palindrome or not
Published under:
Tutorials,
VB Scripts
Subscribe to:
Post Comments (Atom)
This comment has been removed by a blog administrator.
ReplyDeletepls send me a vbscript program that containes a textbox to accept a string and a button.when user clicks the button the script checks whether the string is palindrome or not
ReplyDeleteabove related query with out using reverse string function
ReplyDeletesame as above query with out using reverse string function how to write logic please help me
ReplyDeleteDim str1, rstr1,nCnt1, i
Deletestr1= inputbox("Enter a string")
rstr1=""
'reversing the string
For i=len(str1) to 1 step -1
rstr1=rstr1&mid(str1,i,1)
Next
msgbox("the reverse of the entered string is:"&rstr1)
'comparing the string to check if it is palindrome
If strcomp(str1,rstr1) Then
msgbox("the entered string is palindrome")
End If
Dim str1, rstr1,nCnt1, i
Deletestr1= inputbox("Enter a string")
rstr1=""
'reversing the string
For i=len(str1) to 1 step -1
rstr1=rstr1&mid(str1,i,1)
Next
msgbox("the reverse of the entered string is:"&rstr1)
'comparing the string to check if it is palindrome
If strcomp(str1,rstr1)=0 Then
msgbox("the entered string is palindrome")
End If
how to write a palindrome program without using string function in VB script?
ReplyDeletestr = "xyzyssda"
ReplyDeletestrReverse = ""
For n = len(str) to 1 Step - 1
strReverse = strReverse&Mid(str,n,1)
Next
Msgbox Trim(strReverse)
'Try this code out
this script is not working and showing the error from the strReverse step.
Deletejust adding of above prog
ReplyDeletedim a,b
str = inputbox("enter the string:")
For n = len(str) to 1 step- 1
b=Mid(str,n,1)
a = a+b
Next
Msgbox ("the string is"&a)
if str=a then
msgbox "this is a palandrome"
else
msgbox "it's not a palandrome"
end if
please tel me whether third party tool can be accessed using the script
ReplyDeleteDid any one pls advice me how to print a palindrome string using for loop and if condition?
ReplyDeleteDim str1, rstr1,nCnt1, i
ReplyDeletestr1= inputbox("Enter a string")
rstr1=""
'reversing the string
For i=len(str1) to 1 step -1
rstr1=rstr1&mid(str1,i,1)
Next
msgbox("the reverse of the entered string is:"&rstr1)
'comparing the string to check if it is palindrome
If strcomp(str1,rstr1)=0 Then
msgbox("the entered string is palindrome")
else
msgbox("the entered string is not palindrome")
End If
" Hi This will work perfectly for Whether string is Polindrome or not
ReplyDeleteDim str1, rstr1,nCnt1, i
str1= inputbox("Enter a string")
rstr1=""
'reversing the string
For i=len(str1) to 1 step -1
rstr1=rstr1&mid(str1,i,1)
Next
msgbox("the reverse of the entered string is:"&rstr1)
'comparing the string to check if it is palindrome
If strcomp(str1,rstr1)=0 Then
msgbox("the entered string is palindrome")
else
msgbox("the entered string is not palindrome")
End If
'Simplified program
ReplyDeleteDim str,strRev
str = InputBox("Enter the Name")
strRev = StrReverse(str)
find = 0
length_str = Len(str)
For i = 1 to Len(str)/2
If (mid(str,i,1) = mid(str,length_str,1)) Then
MsgBox "YES"
length_str = length_str-1
find = 0
else
find = 1
Exit for
End If
Next
If find = 0 Then
MsgBox str&" is Polindrome"
else
MsgBox str&" is not Polindrome"
End If