Simple Application That Checks for Palindrome of A string with different data types 600459– Visual Programming Anna University lab manual download fourth semester - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Saturday, January 29, 2011

Simple Application That Checks for Palindrome of A string with different data types 600459– Visual Programming Anna University lab manual download fourth semester

Simple Application That Checks for Palindrome of A string with different data types 600459– Visual Programming Anna University lab manual download fourth semester

  1. Aim:

            To develop a simple application to reverse a given string and to check whether the string is palindrome and concatenate two strings and to search a substring in a string


Controls Used:

            Labels
            Textboxes
            Command Buttons



Algorithm:

1.   Start a new project by selecting standard exe from  new project dialog box
  1. Add a textbox and command buttons to the form
  2. Add appropriate code for command buttons

Source code:
Option Explicit
Dim str1 ,str2 ,str3 As String
Dim i,j ,l m, n As integer

Private Sub cmd_concat_Click()
Txt_concat.Text = txt_fir.Text & txt _sec.Text
End Sub
Private Sub cmd_palinClick()
Str1=Trim(txt_fir.Text)
l=Len(str1)
for i= 1 to 1 step -  1
str3=str3 + Mid (str1, I, 1)
next i
txt_rev.Text =  str3
if str1 = str3 then
Msgbox “String is a palindrome”
Else
Msgbox “String is not a Palindrome “
End if
End sub

Private Sub cmd_res_Click()
Txt_fir.Text = “ “
Txt_sec.Text = “ “
Txt_concat.Text = “ “
Txt_rev.Text = “ “
Txt_fir.SetFocus
End Sub

Private Sub cmd_sub_Click ()
Dim flag As Boolean
Str1 = Trim(txt_fir.Text)
Str2 = Trim(txt_sec.Text)
m=len(str1)
n=len(str2)
For i = 1 to m
For j = 1 to n
If(mid(str1 , I ,1) = Mid(str2 , j , l) or Mid(str1 ,I 1)<> “ “ ) Then
Flag=true
Else
Flag=false
End if
Next j
Next i
If flag= true then
Msgbox “Substring of string one”
Else
Msgbox “Not a substring of string one”
End if
End sub



No comments:

Post a Comment