Você está na página 1de 88

ANNAMALAI UNIVERSITY Department of Computer Science and Engineering LAB MANUAL

for

86708 VISUAL PROGRAMMING, C# and .NET LAB

November 2010 April 2011

Lab In-charges
A1 Batch A2 Batch B Batch C - Batch D - Batch E1 - Batch E2 - Batch F - Batch G - Batch - Ms. A. Suhasini - Ms. T.S. Subashini - Mr. G. Ramachandran - Ms. N. J. Nalini - Mr. P. Sudhakar - Mr. R. Saminathan - Mr. N.Kumaran - Ms. G. Indirani - Ms. L. R. Sudha

ANNAMALAI UNIVERSITY Department of Computer Science and Engineering List of Experiments 86708 VISUAL PROGRAMMING, C# and .NET LAB
PROGRAMME: B.E. (CSE) YEAR: Third Year SEMESTER: VI BATCH: A, B, C, D, E, F & G

Visual Basic
1. 2. 3. 4. 5. 6. 7. 8. 9. Program to calculate the simple interest and compound interest. Program to generate Fibonacci series. Program to design a Scientific Calculator. Program to perform various string operations. Program to perform various matrix operations. Program to create a simple text editor. Program to perform free hand drawing. Program to create simple MDI text editor. Program to create a database.

Visual C ++
10. 11. 12. 13. 14. 15. 16. Program to find whether a string is palindrome or not. Program to generate the Fibonacci and factorial series. Program to perform matrix multiplication. Program for coping a file. Program to count the number of mouse clicks. Program to insert an ActiveX Control. Program to create a message box.

C#
17. 18. 19. 20. 21. 22. 23. Program to prepare a mark sheet with details. Program to deposit and withdraw money from an account. Program to perform basic arithmetic operations. Program to find the area of square and rectangle. Program to display employee details. Program to enter and display book details in a library. Program to assign priority to thread and check whether they are alive.

. NET
24. 25. Program to read the password and display it. Program to show which button has been clicked by user.

Visual Basic Ex No.1


Aim: To write a visual basic program to calculate the simple interest and compound interest. Algorithm: 1. Start 2. Design the form with five-text box and one command button and appropriate message is displayed in label box 3. Declare variable as general 4. Write the script in the click event on the command button 5. set p=Text1.Text 6. set n=Text2.Text 7. set r=Text3.Text 8. si=(p*n*r)/100 9. Ci=p*(1+r/100)^n 10. Text4.Text=si 11. Text5.Text=Ci 12. Stop Property Setting: Property of principle label box Name=label1 Caption=Principle Property of rate of interest label box Name=label2 Caption=Rate of interest Property of Time label box Name=label3 Caption=Time Property of interest label box Name=label4 Caption=Result Property of Text box Name=Text1 Caption=""

Interest Calculation

Property of Text box Name=Text2 Caption="" Property of Text box Name=Text3 Caption="" Property of Text box Name=Text4 Caption="" Property of simple interest command button Name=Command1 Caption=Simple interest Property of compound interest command button Name=Command2 Caption=Compound interest Property of clear command button Name=Command3 Caption=clear Property of Exit command button Name=command4 Caption=Exit Form:

Source Code: Dim p, r As Double Dim n As Integer

Private Sub Command1_Click() p = Val(Text1.Text) r = Val(Text2.Text) n = Val(Text3.Text) Text4.Text = "" Text4.Text = (p * n * r) / 100 End Sub Private Sub Command2_Click() p = Val(Text1.Text) r = Val(Text2.Text) n = Val(Text3.Text) Text4.Text = "" Text4.Text = p * (1 + r / 100) ^ n End Sub Private Sub Command3_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" End Sub Private Sub Command4_Click() End End Sub Output:

Result: Thus a visual basic program has been written to calculate the simple and compound interest and verified with various samples.

Ex No.2
Aim:

Fibonacci Series

To write a visual basic program to create a Fibonacci series. Algorithm: 1. Start. 2. Create a form & replace all the controls that are needed. 3. Under the click event of the command button result, write the codes. 4. Initialize last val,tot and cur val to l . 5. Display the tot and curval in the textbox and initialize l to 1. 6. Do the steps untill i<=n-2 a) Put tot=lastval+curval. b) Equate lastval &curval. c) Equate curval&tot. d) Display the tot in the textbox. 7. End the loop. 8. Stop. Property Setting: Property of label box Name=label1 Caption=Enter the value Property of compute command box Name=command1 Caption=Compute Property of exit command box Name=command2 Caption=Exit Property of list box Name=listbox1 Caption=""

appropriate

Form:

Source Code: Private Sub Command1_Click() Dim f1, f2, f3, i As Integer f1 = -1 f2 = 1 n = Val(Text1.Text) For i = 1 To n f3 = f1 + f2 List1.AddItem (f3) f1 = f2 f2 = f3 Next i End Sub Private Sub Command2_Click() End End Sub

Output:

Result: Thus a visual basic program has been written to calculate the Fibonacci series and verified with various samples.

Ex No.3
Aim:

Design a Scientific calculator

To create a scientific calculator using control arrays using visual basic environment. Algorithm: 1. Start. 2. Add the controls according to the below table. 3. Stop. Property Setting: Control Text Box Command Text2 Command1 Command2 Command3 Command4 Command5 Command6 Command7 Command8 Command9 Command10 Command 11 Command 12 Command 13 Command 14 Command 15 Command 16 Command 17 Command 18 Command 19 Command 20 Command 21 Command 22 Command 23 Command 24 Command 25 Command 26 Command 27 Command 28 Command 29 Command 30 Name Property Text1 Caption, Index Caption, Index Caption, Index Caption, Index Caption, Index Caption, Index Caption, Index Caption, Index Caption, Index Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Caption Text 1, 1 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9, 9 . 0 = + * / x^2 x^3 x^4 Sqrt mod sin cos tan 10^x 1/x x! Pi C Exit Value Text

Form:

Source Code: Dim a, b, c, d As Variant Private Sub Command1_Click() Text1.Text = Text1.Text & 1 End Sub Private Sub Command10_Click()

Text1.Text = Text1.Text & "." End Sub Private Sub Command11_Click() Text1.Text = Text1.Text & 0 End Sub Private Sub Command12_Click() b = Val(Text1.Text) Text1.Text = " " If c = "+" Then d=a+b Text1.Text = d ElseIf c = "-" Then d=a-b Text1.Text = d ElseIf c = "*" Then d=a*b Text1.Text = d ElseIf c = "/" Then d=a/b Text1.Text = d ElseIf c = "mod" Then d = a Mod b Text1.Text = d End If End Sub Private Sub Command13_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " c = "+" End If End Sub Private Sub Command14_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " c = "-" End If End Sub Private Sub Command15_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " c = "*"

End If End Sub Private Sub Command16_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " c = "/" End If End Sub Private Sub Command17_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = a * a End If End Sub Private Sub Command18_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = a * a * a End If End Sub Private Sub Command19_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = a * a * a * a End If End Sub Private Sub Command2_Click() Text1.Text = Text1.Text & 2 End Sub Private Sub Command20_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " Text1.Text = (a) ^ 0.5 End If End Sub Private Sub Command21_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = " " c = "mod"

End If End Sub Private Sub Command22_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) + (3.14 / 180) Text1.Text = " " Text1.Text = Sin(a) End If End Sub Private Sub Command23_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) + (3.14 / 180) Text1.Text = " " Text1.Text = Cos(a) End If End Sub Private Sub Command24_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) + (3.14 / 180) Text1.Text = " " Text1.Text = Tan(a) End If End Sub Private Sub Command25_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = 10 ^ a End If End Sub Private Sub Command26_Click() If Trim(Text1.Text) <> " " Then a = Val(Text1.Text) Text1.Text = 1 / a End If End Sub Private Sub Command27_Click() Dim s, n, i As Integer If Trim(Text1.Text) <> " " Then n = Val(Text1.Text) Text1.Text = " " s=1 For i = 1 To n s=s*i

Next i Text1.Text = s End If End Sub Private Sub Command28_Click() Text1.Text = Val(Text1.Text) * 3.14 End Sub Private Sub Command29_Click() Text1.Text = " " End Sub Private Sub Command3_Click() Text1.Text = Text1.Text & 3 End Sub Private Sub Command30_Click() End End Sub Private Sub Command4_Click() Text1.Text = Text1.Text & 4 End Sub Private Sub Command5_Click() Text1.Text = Text1.Text & 5 End Sub Private Sub Command6_Click() Text1.Text = Text1.Text & 6 End Sub Private Sub Command7_Click() Text1.Text = Text1.Text & 7 End Sub Private Sub Command8_Click() Text1.Text = Text1.Text & 8 End Sub Private Sub Command9_Click() Text1.Text = Text1.Text & 9 End Sub

Output:

Result: Thus a visual basic program has been written to design a scientific calculator and verified with various samples.

Ex No.4
Aim:

String Operation

To write a visual basic program to performing string operations based on the user choice. Algorithm: 1. Start 2. read the string 1 & string 2 3. get the choice from the user 4. if choice=compare then 5. strcomp(string1,string2) 6. Else if choice=concat,then 7. print the concatenated string in textbox 8. Else if choice=replace,then 9. Exchange the string 10. Else if choice=length,then 11. Find the length 12. Else if choice=trim,then 13. remove space 14. Else if choice=reverse,then 15. strreverse(string 1) 16. Else if choice=space,then 17. add space 18. Else if choice=conversion,then 19. convert the cases 20. stop Property Setting: Property of String1 label box Name=label1 Caption=String1 Property of String2 label box Name=String2 Caption=String2 Property of result label box Name=label3 Caption=result Property of Text box 1 Name=Text1 Caption="" Property of Text box 2

Name=Text2 Caption="" Property of Text box 3 Name=Text3 Caption=""

Property for stringlen command box Name=Command2 Caption=length Property for stringcat command box Name=Command5 Caption=concat Property for stringreplace command box Name=Command1 Caption=replace Property for stringcomp command box Name=Command7 Caption=compare Property for stringspace command box Name=Command3 Caption=space Property for stringrev command box Name=Command6 Caption=reverse Property for exit command box Name=Command10 Caption=exit Property for clear command button Name=Command9 Caption=clear Property for option button Name=opt1 Caption=option1

Form:

Source Code: Private Sub Command1_Click() Dim a, b As String a = Text1.Text b = Text2.Text Text3.Text = Replace(a, "a", b, 1, 1) End Sub Private Sub Command10_Click() End End Sub Private Sub Command2_Click() Text3.Text = Len(Text1) End Sub Private Sub Command3_Click() Dim a As String a = Text1.Text Text3.Text = Space(5) + a End Sub Private Sub Command4_Click() Dim a As String a = Text1.Text Text3.Text = StrConv(a, 1) End Sub

Private Sub Command5_Click() Dim a As String a = Text1.Text b = Text2.Text Text3.Text = a + b End Sub Private Sub Command7_Click() Dim a, b As String a = Text1.Text b = Text2.Text Text3.Text = StrReverse(a) End Sub Private Sub Command6_Click() Dim a As String a = Text1.Text Text3.Text = StrComp(a, b) End Sub Private Sub Command8_Click() Dim a As String a = Text1.Text Text3.Text = Trim(a) End Sub Private Sub Command9_Click() Text1.Text = " " Text2.Text = " " Text3.Text = " " End Sub

Output:

Result: Thus a visual basic program has been written to do string operations and verified with various samples.

Ex No.5
Aim:

Matrix Operation

To write a visual basic performing matrix operations. Algorithm: 1. 2. 3. 4. 5. 6. Start design the form with 3 list boxes and six command buttons write the script in the click events of the command button write the script in the addition command button for matrix addition and the appropriate in the command button stop

Property Setting: CONTROL Label1 Label2 Command1 Command2 Command3 Command4 Command5 Command6 List box 1 List box 2 List box 3 Text1 Form: PROPERTY caption caption caption caption caption caption caption caption caption caption caption text multiline VALUE 1st matrix 2nd matrix add sub multiply inverse clear exit listbox1 listbox2 listbox3 true

Source Code: Option Explicit Dim a(10, 10) As Integer Dim b(10, 10) As Integer Dim c(10, 10) As Integer Dim m, n, p, q, i, j, k As Integer Dim str As String Private Sub Command1_Click() List1.Clear List2.Clear List3.Clear l1: m = InputBox("Enter m value") n = InputBox("Enter n value") p = InputBox("Enter p value") q = InputBox("Enter q value") If m <> p Or n <> q Then MsgBox ("Operation not possible") GoTo l1 End If inputa inpub For i = 1 To m str = " " For j = 1 To n c(i, j) = a(i, j) + b(i, j) str = str & c(i, j) & " " Next j List3.AddItem (str) Next i End Sub Private Sub inputa() For i = 1 To m str = " " For j = 1 To n a(i, j) = InputBox("Enter A matrix row wise") str = str & a(i, j) & " " Next j List1.AddItem (str) Next i End Sub Private Sub inpub() For i = 1 To p str = " " For j = 1 To q b(i, j) = InputBox("Enter B matrix row wise") str = str & b(i, j) & " "

Next j List2.AddItem (str) Next i End Sub Private Sub Command2_Click() List1.Clear List2.Clear List3.Clear l1: m = InputBox("Enter m value") n = InputBox("Enter n value") p = InputBox("Enter p value") q = InputBox("Enter q value") If m <> p Or n <> q Then MsgBox ("Operation not possible") GoTo l1 End If inputa inpub For i = 1 To m str = " " For j = 1 To n c(i, j) = a(i, j) - b(i, j) str = str & c(i, j) & " " Next j List3.AddItem (str) Next i End Sub Private Sub Command3_Click() List1.Clear List2.Clear List3.Clear l1: m = InputBox("Enter m value") n = InputBox("Enter n value") p = InputBox("Enter p value") q = InputBox("Enter q value") If n <> p Then MsgBox ("Operation not possible") GoTo l1 End If inputa inpub For i = 1 To m str = " " For j = 1 To q c(i, j) = 0

For k = 1 To p c(i, j) = c(i, j) + a(i, k) * b(k, j) Next k str = str & c(i, j) & " " Next j List3.AddItem (str) Next i End Sub Private Sub Command4_Click() List1.Clear List2.Clear List3.Clear Label2.Visible = False List2.Visible = False m = InputBox("Enter m value") n = InputBox("Enter n value") inputa For i = 1 To n str = " " For j = 1 To m c(i, j) = a(j, i) str = str & c(i, j) & " " Next j List3.AddItem (str) Next i End Sub Private Sub Command5_Click() List1.Clear List2.Clear List3.Clear End Sub Private Sub Command6_Click() End End Sub

Output:

Result: Thus a visual basic program has been written to develop a matrix operation and tested with various samples.

Ex No.6
Aim:

Simulation of text editor

To write a Visual Basic Program to create a simple Text Editor. Algorithm: 1. Place the label, text box, and combo box as shown in form layout. 2. Click tools -> menu editor to open the menu editor . 3. Give the required caption, name in the menu editor window and use left and right arrow buttons to place the menu item as sub menu and use up and down arrows to arrange it in a sequence. 4. Create three menu with lists as shown below Menu Caption File Sub-Menu Caption New Open Save Print Exit Cut Copy Paste Find Replace Font --Bold --Italic --Underline --StrikeThrough Alignment --Right --Left --Center Color --Bgcolor --Forecolor Name mnunew mnuopen mnusave mnuprint mnuexit mnucut mnucopy mnupaste mnufind mnureplace mnufont mnubold mnuitalic mnuunderline mnustrikethru mnualign mnuright mnuleft mnucenter mnucolor mnubgcolor mnuforecolor

Edit

Format

5. To invoke components, click project -> components then select Microsoft common dialog box control from components window . 6. By selecting the operations on menus the corresponding tasks should be performed using common dialog box and clipboard events. Property Setting: Property of Textbox Name=text1 Text=" "

Property of CommonDialogBox Name=cdm1 Menu Editor:

Form:

Source Code: Private Sub mnubgcolor_Click() cdm1.ShowColor Text1.BackColor = cdm1.Color End Sub Private Sub mnubold_Click() Text1.FontBold = Not (Text1.BorderStyle) End Sub Private Sub mnucenter_Click() Text1.Alignment = vbCenter End Sub Private Sub mnucopy_Click() Clipboard.SetText (Text1.Text) End Sub Private Sub mnucut_Click() Clipboard.SetText (Text1.Text) Text1.Text = "" End Sub Private Sub mnuexit_Click() End End Sub Private Sub mnuforecolor_Click() cdm1.ShowColor Text1.ForeColor = cdm1.Color End Sub Private Sub mnuitalic_Click() Text1.FontItalic = Not (Text1.FontItalic) End Sub Private Sub mnuleft_Click() Text1.Alignment = vbLeftJustify End Sub Private Sub mnunew_Click() Text1.Text = "" End Sub Private Sub mnuopen_Click() cdm1.InitDir = "vb98" cdm1.DialogTitle = "file open" cdm1.Filter = "allfiles(*.*)|textfiles(*.txt)|*.txt" cdm1.DefaultExt = "*.*"

cdm1.ShowOpen End Sub Private Sub mnupaste_Click() Text1.SelText = Clipboard.GetText End Sub Private Sub mnuprint_Click() cdm1.ShowPrinter End Sub Private Sub mnuright_Click() Text1.Alignment = vbRightJustify End Sub Private Sub mnusave_Click() cdm1.InitDir = "vb98" cdm1.DialogTitle = "file save" cdm1.Filter = "allfiles(*.*)|*.*" cdm1.DefaultExt = "txt" cdm1.ShowSave End Sub Private Sub mnustrike_Click() Text1.FontStrikethru = Not (Text1.FontStrikethru) End Sub Private Sub mnuunder_Click() Text1.FontUnderline = Not (Text1.FontUnderline) End Sub

Output:

Result: Thus a visual basic program has been written to design a simple text editor and tested with various samples.

Ex No.7
Aim:

Freehand Drawing

To write a visual basic program to create a free hand drawing. Algorithm: 1. 2. 3. 4. Start Design the form by adding 4 command button and 1 combo box Write the script in the appropriate events. Stop

Property Setting: Property of command box Name=command1 caption=size Property of command box Name=command2 caption=color Property of command box Name=command3 caption=clear Property of command box Name=command4 caption=exit Property of Picture box Name=Picture1 Property of Common Dialog Box Name=cd1 Property of combo box Name=combo1 caption=""

Form:

Source Code: Dim clr As OLE_COLOR, drw As Integer Private Sub Command1_Click() Combo1.Visible = True End Sub Private Sub Command2_Click() cd1.ShowColor clr = cd1.Color End Sub Private Sub Command3_Click() Picture1.Cls End Sub Private Sub Command4_Click() End End Sub Private Sub Form_Load() clr = vbBlack For i = 1 To 15 Combo1.AddItem (i) Next i End Sub Private Sub Picture1_MouseDown(button As Integer, shift As Integer, x As Single, y As Single) Combo1.Visible = False If button = vbLeftButton Then

Picture1.PSet (x, y), clr Picture1.DrawWidth = Combo1.Text ElseIf button = vbRightButton Then Picture1.DrawWidth = 1 Picture1.PSet (x, y), Combo1.Text * 10 End If End Sub Private Sub Picture1_MouseMove(button As Integer, shift As Integer, x As Single, y As Single) If button = vbLeftButton Then Picture1.PSet (x, y), clr Picture1.DrawWidth = Combo1.Text ElseIf button = vbRightButton Then Picture1.DrawWidth = 1 Picture1.Circle (x, y), Combo1.Text * 10 End If End Sub Output:

Result: Thus a visual basic program has been written to design a free hand drawing and tested with various samples.

Ex No.8
Aim:

Simple MDI text editor

To create a visual basic application with MDI features and text editing capabilities and also explaining the tool bar, menu bar, status bar, image list box controls. Algorithm: In MDI Form ---Select Microsoft windows common control and Microsoft common dialog control from Project->Components Create the menu bar as follows

1.Add this image box from the left panel

2.Create 6 images using paint for new, open, save, cut, copy and paste respectively 3.Select the image box and double-click the custom from the properties present in the right pane. 4.Select images tab 5.Click Insert Pictures command button 6.Select the 6 pictures from the desired location(which u created in step 2)

7.Click OK. 8.Double click Toolbar icon from left pane

9.Select toolbar on form (below the menu bar of your form) 10.Double click custom from properties(on right pane) 11.Select Button tab 12.Click insert button (6 times) and also number the image text field with corresponding number of index

13.Select General tab 14.Select Imagelist list box 15.Select the Imagelist1 that u created before.

16.Add a Common dialog box and name it as comdg. The resulting form will be something like this

In Form1 1.Add a rich text box name it as rt 2.Rich text box is available in Project->components->Microsoft Rich Text Box

3.In form1 in properties select MDIChild=True Source Code: Private Sub MDIForm_Load() Static n As Integer End Sub Private Sub mnucopy_Click() Clipboard.SetText (MDIForm1.ActiveForm.ActiveControl.SelText) End Sub Private Sub mnucut_Click() Clipboard.SetText (MDIForm1.ActiveForm.ActiveControl.SelText) MDIForm1.ActiveForm.ActiveControl.SelText = " " End Sub Private Sub mnunew_Click() Static n1 As Integer filenam = " " n1 = n1 + 1 Dim nf As New Form1 nf.Show MDIForm1.ActiveForm.Caption = "untitled" + Str(n1) End Sub Private Sub mnuopen_Click() comdg.ShowOpen filenam = " " n1 = n1 + 1 Dim nf As New Form1 nf.Show nf.rt.FileName = comdg.FileName filenam = comdg.FileName

End Sub Private Sub mnupaste_Click() MDIForm1.ActiveForm.ActiveControl.SelText = Clipboard.GetText() End Sub Private Sub mnusave_Click() If Len(filenam) <> 0 Then MDIForm1.ActiveForm.activeobject.SaveFile (filenam) Else Call mnusaveas_Click End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button) If (Button.Index = 1) Then Call mnunew_Click ElseIf (Button.Index = 2) Then Call mnuopen_Click ElseIf (Button.Index = 3) Then Call mnusave_Click ElseIf (Button.Index = 4) Then Call mnucut_Click ElseIf (Button.Index = 5) Then Call mnucopy_Click ElseIf (Button.Index = 6) Then Call mnupaste_Click End If End Sub Private Sub mnusaveas_Click() comdg.ShowSave MDIForm1.ActiveForm.ActiveControl.SaveFile (comdg.FileName) filenam = comdg.FileName End Sub Private Sub rt_MouseDown(Button As Integer, shift As Integer, x As Single, y As Single) If Button = 2 Then PopupMenu mnuedit End If End Sub

Output:

Result: Thus a visual basic program has been written to design a simple text MDI text editor and tested with various samples.

Ex No.10
Aim:

Database

To create a visual basic application for doing basic functions in an database. Algorithm: 1.Start 2.Create a table as follows Add-Ins->Visual DataManager

File->New->Microsoft Access->Version 7.0 MDB Save file.

Right click on properties(in Database Window)

Select New Table

Enter table name Click Add Field button Enter the Name and select the desired type in Type combo box.

Click ok. Similarly enter all the field names and its corresponding type. When finished click close.

Click Build the table

Double click the table name. Click Add and enter the corresponding field details and update it. Similarly enter all the records. 3.Click Utility->Data form designer

4.Enter the form name as Form2 5.Select Record in RecordSource listbox.

6.Click the >> button in the middle and then click Build The Form 7.Stop. Form: You will get something like this with in built code as given below.

Source code: Private Sub cmdAdd_Click() Data1.Recordset.AddNew End Sub Private Sub cmdDelete_Click() 'this may produce an error if you delete the last 'record or the only record in the recordset Data1.Recordset.Delete Data1.Recordset.MoveNext End Sub

Private Sub cmdRefresh_Click() 'this is really only needed for multi user apps Data1.Refresh End Sub Private Sub cmdUpdate_Click() Data1.UpdateRecord Data1.Recordset.Bookmark = Data1.Recordset.LastModified End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub Data1_Error(DataErr As Integer, Response As Integer) 'This is where you would put error handling code 'If you want to ignore errors, comment out the next line 'If you want to trap them, add code here to handle them MsgBox "Data error event hit err:" & Error$(DataErr) Response = 0 'throw away the error End Sub Private Sub Data1_Reposition() Screen.MousePointer = vbDefault On Error Resume Next 'This will display the current record position 'for dynasets and snapshots Data1.Caption = "Record: " & (Data1.Recordset.AbsolutePosition + 1) 'for the table object you must set the index property when 'the recordset gets created and use the following line 'Data1.Caption = "Record: " & (Data1.Recordset.RecordCount * (Data1.Recordset.PercentPosition * 0.01)) + 1 End Sub Private Sub Data1_Validate(Action As Integer, Save As Integer) 'This is where you put validation code 'This event gets called when the following actions occur Select Case Action Case vbDataActionMoveFirst Case vbDataActionMovePrevious Case vbDataActionMoveNext Case vbDataActionMoveLast Case vbDataActionAddNew Case vbDataActionUpdate Case vbDataActionDelete Case vbDataActionFind Case vbDataActionBookmark Case vbDataActionClose End Select

Screen.MousePointer = vbHourglass End Sub Output:

Result: Thus a visual basic program has been written to design a database and tested with various samples.

VISUAL C++
Open a new file 1.File->New 2.Select MFC App (10 to 15) WizardWin32Application (16) 3.Enter Project name 4.Select desired Location 5.Click ok 6.Select Dialog based(10 to 15) A simple Win32 Application(16) 7.Click Finish To create member variables 1.Select control 2.Right click and select class wizard 3.Select Member variables tab 4.Click Add Variable button 5.Enter variable name and select variable category and type 6.Click OK Note: As soon as the form opens up for the first time, delete whatever is in the form (buttons and text box) Here label is Static text box and text box is edit box. Drag and drop controls. To change controls properties->right click on control and select properties. To enter code, double click the button. Press to execute

Ex. No 11
Aim:

Palindrome or Not

To write a MFC program to find whether a given string is palindrome or not using Visual C++ Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop Controls used: Control Name Button button1 Button button2 Property Caption Caption Value Is Palindrome Exit Variable name m_edit1

Member variables: Control name Category IDC_EDIT1 Value Form design:

Type CString

Source code: void CMy2Dlg::OnButton1() { CString s; UpdateData(true); s=m_edit1; s.MakeReverse();

if(s==m_edit1) SetDlgItemText(IDC_EDIT2,m_edit1 +" is palindrome"); else SetDlgItemText(IDC_EDIT2,m_edit1 +" is not palindrome"); } void CMy2Dlg::OnButton2() { exit(0); }

Output:

Result: Thus a win32 application has been created to display a whether a given string is palindrome or not using VC++.

Ex. No 12
Aim:

Fibonacci and Factorial

To write a MFC program to find the Fibonacci and factorial of a number using Visual C++. Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop Controls used: Radio Button Radio Button List Box Button Radio1 Radio2 List1 Button1 long Clistbox Caption Caption Sort Caption Factorial Fibonacci False Exit m_edit1 m_list1

Member variables: IDC_EDIT1 Value IDC_LIST1 Control Form design:

Source code: void CMy3Dlg::OnRadio1() { int s,a=1,i;

char c[10]; UpdateData(true); m_list1.ResetContent(); s=m_edit1; for(i=1;i<=s;i++) { a=a*i; } itoa(a,c,10); m_list1.AddString(c); } void CMy3Dlg::OnRadio2() { long s,a,b,c,i; char z[100]; UpdateData(true); m_list1.ResetContent(); a=-1; b=1; s=m_edit1; for(i=0;i<s;i++) { c=a+b; a=b; b=c; itoa(c,z,10); m_list1.AddString(z); } } void CMy3Dlg::OnButton1() { exit(0); }

Output:

Result: Thus a win32 application has been created to display a whether a given string is palindrome or not using VC++ .

Ex. No 13
Aim:

Matrix Multiplication

To write a MFC program to find the multiplication of 2 matrices using Visual C+ + Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop Controls used: Button Button button1 button2 Caption Caption Multiply Exit

Member variables: IDC_EDIT1 IDC_EDIT2 IDC_EDIT3 IDC_EDIT4 IDC_EDIT5 IDC_EDIT6 IDC_EDIT7 IDC_EDIT8 IDC_EDIT9 IDC_EDIT10 IDC_EDIT11 IDC_EDIT12 IDC_EDIT13 IDC_EDIT14 IDC_EDIT15 IDC_EDIT16 IDC_EDIT17 IDC_EDIT18 Value Value Value Value Value Value Value Value Value Value Value Value Value Value Value Value Value Value int int int int int int int int int int int int int int int int int int A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 B2 B3 B4 B5 B6 B7 B8 B9

Form design:

Source code: void CMy4Dlg::OnButton1() { UpdateData(true); SetDlgItemInt(IDC_EDIT19,((A1*B1)+(A2*B4)+(A3*B7))); SetDlgItemInt(IDC_EDIT20,((A1*B2)+(A2*B5)+(A3*B8))); SetDlgItemInt(IDC_EDIT21,((A1*B3)+(A2*B6)+(A3*B9))); SetDlgItemInt(IDC_EDIT22,((A4*B1)+(A5*B4)+(A6*B7))); SetDlgItemInt(IDC_EDIT23,((A4*B2)+(A5*B5)+(A6*B8))); SetDlgItemInt(IDC_EDIT24,((A4*B3)+(A5*B6)+(A6*B9))); SetDlgItemInt(IDC_EDIT25,((A7*B1)+(A8*B4)+(A9*B7))); SetDlgItemInt(IDC_EDIT26,((A7*B2)+(A8*B5)+(A9*B8))); SetDlgItemInt(IDC_EDIT27,((A7*B3)+(A8*B6)+(A9*B9))); } void CMy4Dlg::OnButton2() { exit(0); }

Output:

Result: Thus a win32 application has been created to perform multiplication of 2 matrices using VC++.

Ex. No 14
Aim:

File Operations

To write a MFC program to copy a file using Visual C++ Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop

Controls used: Button button1 Button buttton2 Member variables: IDC_EDIT1 Value IDC_EDIT2 Value Form design:

caption caption Cstring Cstring

Copy Exit m_edit1 m_edit2

Source code: void CMy5Dlg::OnButton1() { char szbuffer[100]; UINT nACTUAL=0,pos=0; CFile myfile,myfile1; UpdateData(true); myfile.Open(m_edit1,CFile::modeReadWrite); myfile.Open(m_edit2,CFile::modeCreate|CFile::modeReadWrite); while(1) { myfile.Seek(pos,CFile::begin); nACTUAL=myfile.Read(szbuffer,100); myfile.Write(szbuffer,100); pos=pos+nACTUAL; if(nACTUAL==0) { MessageBox("File Copied"); exit(0);

} } } void CMy5Dlg::OnButton2() { exit(0); }

Output:

Result: Thus a win32 application has been created to perform file operation using VC++.

Ex. No 14
Aim:

Mouse Interface

To write a MFC program to find the number of left and right mouse clicks using Visual C++. Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop Note: Right click on form and select events Double click the following WM_LBUTTONDBCLK WM_LBUTTONDOWN WM_RBUTTONDBLCLK WM_RBUTTONDOWN

Controls used: Button button1 Form design:

Caption

Exit

Source code: void CMy6Dlg::OnButton1() { exit(0); } int count1,count2; void CMy6Dlg::OnLButtonDown(UINT nFlags, CPoint point) { count1++; SetDlgItemInt(IDC_EDIT1,count1); CDialog::OnLButtonDown(nFlags, point); } void CMy6Dlg::OnLButtonDblClk(UINT nFlags, CPoint point) { count1++; SetDlgItemInt(IDC_EDIT1,count1); CDialog::OnLButtonDblClk(nFlags, point); } void CMy6Dlg::OnRButtonDblClk(UINT nFlags, CPoint point) {

count2++; SetDlgItemInt(IDC_EDIT2,count2); CDialog::OnRButtonDblClk(nFlags, point); } void CMy6Dlg::OnRButtonDown(UINT nFlags, CPoint point) { count2++; SetDlgItemInt(IDC_EDIT2,count2); CDialog::OnRButtonDown(nFlags, point); }

Output:

Result: Thus a win32 application has been created for the mouse interface using VC++.

Ex. No 15
Aim:

Active-X Controls

To write a MFC program to insert an ActvieX control using Visual C++. Algorithm: 1. Start 2. Create form as required 3. Enter source code 4. Stop Note: To insert ActiveX control Right-click on form->Insert ActiveX Control->Calendar Control 8.0 Controls used: Button button1 Button button2 Form design: caption caption Message Exit

Source code: void CMy7Dlg::OnButton1() { MessageBox("ActiveX Control"); } void CMy7Dlg::OnButton2() { exit(0); } Output:

Result: Thus a win32 application has been created to insert a ActiveX control using VC+ +.

Ex. No 16
Aim:

Message Box display

To write a Win32 program to create a Message Box using Visual C++. Algorithm: 1. Type the code in the class file(present in Globals). 2. End Source code: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { DWORD dwmemavail; char szbuffer[80]; dwmemavail=GetFreeSpace(0); wsprintf(szbuffer,"Memory aailabale: %lu",dwmemavail); MessageBox(NULL,szbuffer,"GLOBEL MEM", MB_OK); return 0; }

Output:

Result: Thus a win32 application has been created to display a Message-box using VC++.

C Sharp Ex.No. 17
Aim: To prepare a Mark sheet for n students using arrays and structures in c#. Algorithm (a): 1. Declare the required fields with required size 2. To get the data, create a method getdata() and get the data 3. To manipulate the data, create a method putdata() and print the result 4. To print the data, create a method putdata() and print the result Algorithm (b): 1. Define a structure named student 2. To get the data, create a method getdata() and get the data 3. To manipulate the data, create a method putdata() and print the result 4. To print the data, create a method putdata() and print the result Source code: using System; struct student { public String name; public int rollno; public int mark1; public int mark2; } class marksheet { public static void Main() { student[] s=new student[10]; int I; Console.Write(Enter the number of students:); string no=Console.ReadLine(); int n=Convert.ToInt32(no); for(i=1;i<=n;i++) { Console.Write(Enter student{0}s name:,i); s[i].name=Console.ReadLine(); Console.Write(Enter student{0}s roll no:,i); String roll=Console.ReadLine(); s[i].rollno=Convert.ToInt32(roll); Console.Write(Enter student{0}s 1st mark:,i); String m1=Console.ReadLine(); s[i].mark1=Convert.ToInt32(m1);

PREPARE A MARKSHEET

Console.Write(Enter student{0}s 2nd mark:,i); String m2=Console.ReadLine(); s[i].mark2=Convert.ToInt32(m2); } for(i=1;i<=n;i++) { Console.WriteLine(\n Studentd {0}s Marksheet,i); Console.WriteLine(Name:{0},s[i].name); Console.WriteLine(Roll No:{0},s[i].rollno); Console.WriteLine(Mark 1:{0},s[i].mark1); Console.WriteLine(Mark 2:{0},s[i].mark2); float avg=(float)((s[i].mark1+s[i].mark2)/2); Console.WriteLine(Average:{0},s[i].avg); Console.ReadLine(); } } } Output: Enter the no.of students:2 Enter Student1sname=AAA Enter student1s roll no=111 Enter student1s mark1=80 Enter student1s mark2=70 Enter Student2sname=BBB Enter student2s roll no=112 Enter student2s mark1=70 Enter student2s mark2=60 Student1s Marksheet Name: AAA Roll No: 111 Mark1: 80 Mark2: 70 Average: 75 Student2s Marksheet Name: BBB Roll No: 112 Mark1: 70 Mark2: 60 Average: 65 Result Thus the mark sheet has been created and successfully executed using arrays and structures in C#.

Ex.No. 18
Aim:

BANKING TRANSACTIONS

To develop a C # program to check the account balance for some n persons using namespace concepts. Algorithm(a): 1. Create a namespace named compbalance 2. Under that create a class named balance, declare the variable names for balance amount and personality name and create one more method show () within the same class to the balance manipulation. 3. Save the file as dllone.cs 4. compile it 5. After compilation, with a new window open another file named dlltwo.cs 6. Include the namespace compbalance within the dlltwo.cs using using compbalance; 7. Within that create instance for the class addclass and given the data 8. Using the method show () which is in addclass under the namespace compbalabce 9. Print the result Source Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using mymeth; class Banking { public static void Main(string[] args) { Console.WriteLine("Banking"); Console.WriteLine("Enter the balance amount:"); String bal = Console.ReadLine(); int balance = Convert.ToInt32(bal); Console.WriteLine("Deposit or Withdraw?(1.Deposit,2.Withdraw)"); String ch = Console.ReadLine(); int choice = Convert.ToInt32(ch); switch (choice) { case 1: { deposit d = new deposit(); Console.WriteLine("enter amount to be dposited"); String dep = Console.ReadLine(); int depos = Convert.ToInt32(dep); d.depositamt(balance, depos); break; }

case 2: { withdraw w = new withdraw(); Console.WriteLine("enter amount to be withdrawed"); String wd = Console.ReadLine(); int withd = Convert.ToInt32(wd); w.withdrawamt(balance, withd); break; } } Console.ReadLine(); } } namespace mymeth { public class deposit { public void depositamt(int balance, int depos) { balance += depos; Console.WriteLine("Deposititamt is rs{0}", depos); Console.WriteLine("New balance is rs{0}", balance); } } } namespace mymeth { public class withdraw { public void withdrawamt(int balance, int withd) { balance -= withd; Console.WriteLine("Withdrawnamt is rs{0}", withd); Console.WriteLine("New balance is rs{0}", balance); } } } Output: Banking Enter the balance amount 500 Deposit or withdraw? <1.deposit, 2.withdraw> 1 Enter the amount to be deposited 100

deposit amt is Rs.100 new balance is Rs.600 press any key to continue Banking Enter the balance amount 500 Deposit or Withdraw? <1.deposit, 2.withdraw> 2 Enter the amount to be withdrawn 100 withdraw amt is Rs.100 new balance is Rs.400 press any key to continue.. Result: Thus a account balance for some n persons using namespace concepts has been created and successfully executed using C#.

Ex.No. 19
AIM:

A Simple calculator using inheritance

To write a c# program to generate the operation of a simple calculator (Add, Sub, Multiple, Divide) ALGORITHM: step 1:create a class for add. step 2:under that create a method to add the two no. step 3:By inheriting the class add,create a class sub. step 4:under that create a method to subtract the two no. step 5:Again by inheriting the class sub,create a class mul. step 6:create a method to multiply two no. step 7:At last,By inheriting the class mul,create a class div step 8:create a method to divide two no. step 9:using a mainclass and main method manipulate the inherited classes. SOURCE: using System; using System.Collections.Generic; using System.Text; class add { public int compute(int a, int b) { return (a + b); } } class sub : add { new public int compute(int a, int b) { return (a - b); } } class mul : sub { new public int compute(int a, int b) { return (a * b); } } class div : mul { new public int compute(int a, int b)

{ return (a / b); } } class mainclass { public static void main() { div d = new div(); Console.WriteLine("Enter 2 values for a and b"); String s = Console.ReadLine(); String t = Console.ReadLine(); int a = Convert.ToInt32(s); int b = Convert.ToInt32(t); int x = d.compute(a, b); int y = ((mul)d).compute(a, b); int z = ((sub)d).compute(a, b); int p = ((div)d).compute(a, b); Console.WriteLine("Sum:{0}", p); Console.WriteLine("Difference:{0}", z); Console.WriteLine("Product:{0}", y); Console.WriteLine("Quotient:{0}", x); Console.ReadLine(); } }

OUTPUT: Enter 2 values for a and b: 100 50 Sum: 150 Difference: 50 Product: 5000 Quotient: 2 RESULT: Thus the simple calculator has been created and operations are verified using C # program.

Ex.No 20
AIM:

Inheritance and Property

To find the area of the square, rectangle and circle using abstract classes, inheritance and property. ALGORITHM: step 1:create an abstract class shape. step 2:within the class,create an abstract property area. step 3:create a class square with the inherited class shape. step 4:override the abstract property area using the keyword "override". step 5:create a class cube with the inherited class shape. step 6:override the abstract property area using the keyword "override". step 7:create a class rectangle with the inherited class shape. step 8:override the abstract property area using the keyword "override" step 9:create a mainclass and main method and manipulate the classes. SOURCE CODE: using System; using System.Collections.Generic; using System.Text; abstract class shape { public string myid; public shape(string s) { myid = s; } abstract public double area { get; } public override string ToString() { return "\n The area of the " + myid + "is" + area + "sq.units"; } } class square : shape { public int side; public square(int i, string s) : base(s) { side = i; }

public override double area { get { return side * side; } } } class rect : shape { public int lt, bt; public rect(int l, int b, string s) : base(s) { lt = l; bt = b; } public override double area { get { return lt * bt; } } } class mainclass { public static void Main() { Console.WriteLine("Enter side of the square:"); string sq = Console.ReadLine(); int a = Convert.ToInt32(sq); Console.WriteLine("\n enter the length of the rectangle:"); string l1 = Console.ReadLine(); Console.WriteLine("\n enter the breadth of the rectangle:"); string b1 = Console.ReadLine(); int l = Convert.ToInt32(l1); int b = Convert.ToInt32(b1); shape[] shapes = { new square(a, "Square"), new rect(l, b, "Rectangle") }; foreach (shape s in shapes) { Console.WriteLine(s); } Console.ReadLine(); } }

OUTPUT: Enter side of the square: 4 Enter the length of the rectangle: 30 Enter the breadth of the rectangle: 15 The area of the square is: 16 sq.units The area of the rectangle is: 450 sq.units

RESULT: Thus the area of the square, rectangle and circle has been found using abstract classes, inheritance and Property in C#

Ex.No 21
AIM:

Interface and properties

To develop the c#program for employee details using the concept of interface and properties. ALGORITHM: step 1:create an interace named Iemployee. step 2:under the interface declare the properties for an employee(for eg,name, eno,bp,da...). step 3:create a class employee with the implementation of an interface Iemployee. step 4:Define the properties. step 5:with mainclass and method manipulate it. SOURCE CODE: using System; public interface details { string name { get; set; } string no { get; set; } } public interface emp { string gross { get; set; } string net { get; set; } } class employ:details,emp

{ private string ename; private string eno; public string name { get { return ename; } set { ename=value; } } public string name { get { return eno; } set { eno=value; } } private string gpay; private string npay; public string gross { get { return gpay; } set { gpay=value; } } public string net { get { return npay; } set { npay=value;

} } } class main { public static void Main() { employ e=new employ(); e.name="aaa"; e.no="111"; e.gross="5000"; e.net="10000"; Console.WriteLine(e.name); Console.WriteLine(e.no); Console.WriteLine(e.gross); Console.WriteLine(e.net); } }

OUTPUT: aaa 111 5000 10000 RESULT: Thus the employee detail has been found using the concept of interface and properties of C#.

Ex.No 22
AIM:

Book store processing using Delegates

To write a c# program to find the damaged books in book store processing using delegates. ALGORITHM: step 1:create a namespace named Bookspace. step 2:within the namespace create a structure Book for the bookdetails. step 3:create a delegate for the process for book store. step 4:crfeate an array for storing the book details. step 5:create an another class within that find the total no of books and price of those books. step 6:create one more class to test wheather the book is damaged or not. step 7:print the result. SOURCE CODE: using System; using System.collections; namespace bookstore { public struct book { public string title; public string author; public string qlty; public string price; } public delegate void bookdelegate(book b); public class bookbd { public ArrayList a; public bookbd() { a=new ArrayList(100); } public void addBook() { book b; Console.WriteLine("Enter book title"); b.title=Console.ReadLine(); Console.WriteLine("Enter the book author"); b.author=Console.ReadLine(); Console.WriteLine("Enter the quality of the book.(true-High qlty,falseLow qlty)"); b.qlty=Console.ReadLine();

Console.WriteLine("Enter the price of the book"); b.price=Convert.ToDouble(Console.ReadLine()); Console.WriteLine("__________"); a.Add(b); } public void qltycheck(bookdelegate process) { foreach(book b in a) { if(b.qlty=="true") { process(b); } } } } } namespace bookprocess { using bookstore; public class bookp { public int count=0; public double totprice=0; public void print(book b) { Console.WriteLine("The title is {0} by {1}",b.title,b.author); } public void calc(book b) { count++; totprice=totprice + b.price; } public double avg() { return totprice/count; } } class mainclass { static void main() { bookdb bd=new bookbd(); do { bd.addBook(); Console.WriteLine("Do u wish to continue?(y-yes,n-no)"); }while(Console.ReadLine()=="y" || Console.ReadLine()=="Y");

book p=new bookp(); bd.qltycheck(new bookdelegate(p.print)); bd.qltycheck(new bookdelegate(p.calc)); Console.WriteLine(" The avg price is:Rs{0:#.##}",p.avg()); } } }

OUTPUT: Enter the book title C language Enter the author Balagurusamy Enter the quality of the book,<true-high qlty,false-Low qlty> True Enter the price of the book 200 Do u wish to continue?<y-yes,n-no> N The title is C language by Balagurusamy The avg price is :Rs200 Press any key to continue.. RESULT: Thus the C # program for book store processing using Delegates has been created and verified.

Ex.No 23
AIM:

Thread with priority using isAlive concept.

To develop a c# program for creating the threads with priority using isAlive concept. ALGORITHM: step 1:create a class with constructor and pass the thread name as constructor's argument. step 2:create run function. step 3:In main method,create some threads, with priority highest. step 4:Manipulate it. SOURCE CODE: using System; using System.Threading; public class threads { string name; Thread t1; public thread(string tname,int p) { name=tname; t1=new Thread(new Threadstart(run1)); t1.Name=name; switch(p) { case 0: { t1.Priority=ThreadPriority.Lowest; break; } case 1: { t1.Priority=ThreadPriority.BelowNormal; break; } case 2: { t1.Priority=ThreadPriority.Normal; break; } case 3: { t1.Priority=ThreadPriority.AboveNormal;

break; } case 4: { t1.Priority=ThreadPriority.Highest; break; } } t1.Start(); } public void run1() { try { for(int i=1;i<=5;i++) { Console.WriteLine(name+"Priority:"+t1.Priority+"Iteration:"+i); Thread.Sleep(1000); } } finally { Console.WriteLine(name+" is exiting"); } } public static void Main(string[] args) { threads one=new threads("Thread 1",0); threads one=new threads("Thread 2",1); threads one=new threads("Thread 3",2); threads one=new threads("Thread 4",3); Thread t=Thread.CurrentThread; t.Priority=ThreadPriority.Highest; try{ for(int i=1;i<=5;i++) { Console.WriteLine("\nMain Thread"+i); Thread.Sleep(2000); Console.WriteLine("\n Checking if thread 1 ia alive"); if(one.t1.IsAlive) { Console.WriteLine("Thread 1 is alive"); } else { Console.WriteLine("Thread 1 is dead");

} Console.WriteLine("\n"); } } finally { Console.WriteLine("Main Thread Exiting"); } } } OUTPUT: Main Thread1 Thread 4 Priority:AboveNormalIteration:1 Thread 2 Priority:BelowNormalIteration:1 Thread 3 Priority:NormalIteration:1 Thread 1 Priority:LowestIteration:1 Thread 2 Priority:BelowNormalIteration:2 Thread 4 Priority:AboveNormalIteration:2 Thread 3 Priority:LowestIteration:2 Thread 1 Priority:NormalIteration:2 Checking if thread 1 is alive Thread 1 is alive Main Thread2 Thread 4 Priority:AboveNormalIteration:3 Thread 2 Priority:BelowNormalIteration:3 Thread 3 Priority:NormalIteration:3 Thread 1 Priority:LowestIteration:3 Thread 2 Priority:BelowNormalIteration:4 Thread 4 Priority:AboveNormalIteration:4 Thread 3 Priority:LowestIteration:4 Thread 1 Priority:NormalIteration:4 Checking if thread 1 is alive Thread 1 is alive Main Thread3 Thread 4 Priority:AboveNormalIteration:5 Thread 2 Priority:BelowNormalIteration:5 Thread 3 Priority:NormalIteration:5 Thread 1 Priority:LowestIteration:5 Thread 4 is exiting Thread 2 is exiting Thread 3 is exiting Thread 1 is exiting

Checking if thread 1 is alive Thread 1 is alive Main Thread4 Checking if thread 1 is alive Thread 1 is alive Main Thread5 Checking if thread 1 is alive Thread 1 is dead Main Thread is exiting RESULT: Thus the C# program has been to developed and found the threads with priority using is Alive concept.

. NET Ex.No.24
Aim: To develop a win form for manipulation of the text. Procedure: 1. Type the required program first in c# and save it. 2. Compile it to create the dll file. 3. start->programs->Microsoft VisualStudio.Net7.0->Microsoft VisualStudio.Net7.0(2). 4. In the screen,click File->New->project. 5. In the screen,select windows application. 6. Design the form depend on your need. 7. Set the properties. 8. Add the dll to the project. 9. Now, write the coding for the corresponding control to activate the form. SOURCE CODE: using System; using System.Windows.Forms; public class WinForm:Form { TextBox t1,t2,t3; Button b1; Public WinForm() { t1=new TextBox(); t1.Size=new System.Drawing.Size(150,40); t1.Location=new System.Drawing.Point(100,50); t1.AcceptsTab=true; t1.Multline=true; t1.ScrollBars=ScrollBars.Vertical; t2=new TextBox(); t2.Size=new System.Drawing.Size(150,40); t2.Location=new System.Drawing.Point(100,120); t2.CharacterCasing=System.Windows.Forms.CharacterCasing.Upper; t3=new TextBox(); t3.Size=new System.Drawing.Size(150,40); t3.Location=new System.Drawing.Point(100,200); t3.PASSWORDchar=$; b1=new Button(); b1.Size=new System.Drawing.Size(50,20); b1.Location=new System.Drawing.Point(100,200); b1.Text=click me; this.Controls.Add(t1);

To read the password and display

this.Controls.Add(t2); this.Controls.Add(t3); this.Controls.Add(b1); b1.Click+=new EventHandler(OnClick); } public void OnClick(Object o,EventArgs e) { MessageBox.Show(Your password is:+t3.Text); } } class MainClass { public static void Main() { Applicaton.Run(new WinForm()); } } OUTPUT:

RESULT: Thus the c# program for the manipulation of the text has been created and verified.

Ex.No 25
AIM:

To show which button has been clicked

To develop a winform for manipulation of the toolbar. PROCEDURE: 1.Type the required program first in c# and save it. 2.compile it to create the dll file. 3.start->programs->Microsoft VisualStudio.Net7.0->Microsoft VisualStudio.Net7.0(2). 4.In the screen,click File->New->project. 5.In the screen,select windows application. 6.Design the form depend on your need. 7.Set the properties. 8.Add the dll to the project. 9.Now,write the coding for the corresponding control to activate the form. SOURCE CODE: using System; using System.Windows.Forms; class Winform:Form { Winform() { ToolBar tb=new ToolBar(); ToolBarButton cut=new ToolBarButton(); ToolBarButton copy=new ToolBarButton(); ToolBarButton paste=new ToolBarButton(); cut.Text="cut"; copy.Text="copy"; paste.Text="paste"; tb.Buttons.Add(cut); tb.Buttons.Add(copy); tb.Buttons.Add(paste); this.Controls.Add(tb); this.Text="ToolBar Example"; tb.ButtonClick +=new ToolBarButtonClickEventHandler(OnClick); } public void OnClick(Object o,ToolBarButtonClickEventArgs e) { if(e.Button.Text=="cut") MessageBox.Show("Cut is Clicked"); elseif(e.Button.Text=="copy") MessageBox.Show("Copy is Clicked"); elseif(e.Button.Text=="paste")

MessageBox.Show("Paste is Clicked"); else MessageBox.Show("No Button are clicked"); } public static void Main() { Application.Run(new Winform()); } } OUTPUT:

RESULT: Thus the C# program for manipulation of the toolbar has been created and verified.

Você também pode gostar