KARPAGAM ACADEMY OF HIGHER EDUCATION
(Deemed to be University)
(Established Under section 3 of UGC act 1956)
Accredited with A+ Grade by NAAC in the Second Cycle
Coimbatore-641021.
DEPARTMENT OF COMPUTER SCIENCE
.NET PROGRAMMING PRACTICAL
(22CSU414A)
II [Link] COMPUTER SCIENCE (2022-2025)
NAME :
[Link] :
KARPAGAM ACADEMY OF HIGHER EDUCATION
Coimbatore-21
DEPARTMENT OF COMPUTER
SCIENCE
BONAFIDE CERTIFICATE
REG NO:
This is to certify that this is a bonafide record work done by
……………………………. of II [Link] (Computer Science) during the
academic year January 2024 – May 2024 and submitted for the practical
examination in .NET PROGRAMMING PRACTICAL (22CSU414A) held
on ___________.
Staff-in-charge Head of the Department
Internal Examiner External Examiner
INDEX
[Link] DATE TITLE PAGE NO SIGNATURE
FACTORIAL OF A NUMBER USING
1
FUNCTION
2 STRING MANIPULATION
3 MANIPULATE DATA
TEXT EDITOR USING RICH TEXTBOX
4
METHODS AND PROPERTIES OF
5
LISTBOX
METHODS AND PROPERTIES OF
6
LISTVIEW
7 MDI CONTROL
8 EMPLOYEE DATABASE
9 EMPLOYEE REGISTRATION
10 CANTEEN ORDER
[Link]
FACTORIAL OF A NUMBER USING FUNCTION
DATE :
AIM:
To Develop a program to factorial of a number using function
Algorithm:
Step 1:Open Microsoft Visual Studio 2012 and create a new windows form application.
STEP 2: Click the start to new project click visual basic to windows form applications
then click ok.
Step 3:Add the Label, Button and a TextBox inside theForm.
Step 4:Double click the button and do the following code inside the sub procedure for
getting factorial numbers.
Step 5:run the code.
step 6:out put will disolay in the screen.
CODING:
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim n, f, i As Integer
f=1
n = Val([Link])
For i = 1 To n
f=f*i
Next
MsgBox(“Factorial is :” & f, vbInformation, “Factorial”)
End Sub
Form Design:
Output:
Result:
Thus the above program excuted successfully
[Link]
STRING MANIPULATION
DATE :
AIM :
To write a [Link] program to perform a string Handling Functions.
ALGORITHM :
STEP 1: Open a form and use necessary controls that are required for our applications.
STEP 2: Get two input strings from the user through the TextBox.
STEP 3: Perform the various string manipulation function.
STEP 4: Display the result.
STEP 5: Save and Run the application.
PROGRAM:
Public Class Form1
Dim str1 As String
Dim str2 As String
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
str1 = [Link]
str2 = [Link]
End Sub
Private Sub Button5_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
str1 = [Link]
str2 = [Link]
MsgBox(StrReverse(str1))
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
MsgBox([Link](str1, str2))
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
str1 = [Link]
str2 = [Link]
If ([Link](str1, str2)) Then
MsgBox("Strings are equal")
Else
MsgBox("Strings are not equal")
End If
End Sub
Private Sub Button3_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
str1 = [Link]
MsgBox([Link]())
End Sub
Private Sub Button4_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
str1 = [Link]
str2 = [Link]
MsgBox([Link](3))
MsgBox([Link](2))
End Sub
End Class
OUTPUT:
RESULT:
Various string manipulation has been performed.
[Link]
DATE :
MANIPULATE DATA
AIM :
Develop a [Link] program to create a form, place control and manipulate data.
ALGORITHM :
STEP 1: Open a form and use create controls that are required for form, two label, two
Textbox, Button application.
STEP 2: Get two input strings from the user through the TextBox.
STEP 3: The values using the equation Total=Val([Link])+Val([Link]).
STEP 4: Display the result in the MsgBox.
STEP 5: Save and Run the application.
PROGRAM:
Public Class Form1
Dim form2 As New Form
Dim label1, label2 As Control
Dim txt1, txt2 As Control
Dim btnl As Control
Dim total As Integer
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
[Link] = "Vn"
[Link]()
[Link] = New Size(500, 500)
[Link] = [Link]
End Sub
Private Sub btn1_Click(ByVal sender As Object, ByVal e As [Link])
total = Val([Link]) + Val([Link])
MsgBox(total)
End Sub
Private Sub Form2_Load(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
label1 = New [Link]
[Link] = True
[Link] = New [Link](90, 10)
[Link] = New [Link](31, 51)
[Link] = 0
[Link] = "Enter the mark 01 "
[Link] = [Link]
[Link] = New [Link]("times new Roman", 14, [Link])
[Link] = True
[Link](label1)
label2 = New [Link]
[Link] = True
[Link] = New [Link](90, 70)
[Link] = New [Link](31, 51)
[Link] = 0
[Link] = "Enter the mark 02"
[Link] = [Link]
[Link] = New [Link]("Times new Roman", 14, [Link])
[Link] = True
[Link](label2)
txt1 = New [Link]
[Link] = True
[Link] = New [Link](300, 10)
[Link] = New [Link](51, 71)
[Link] = 0
[Link] = [Link]
[Link] = New [Link]("times new Roman", 14, [Link])
[Link] = True
[Link](txt1)
txt2 = New [Link]
[Link] = True
[Link] = New [Link](300, 70)
[Link] = New [Link](51, 71)
[Link] = 0
[Link] = [Link]
[Link] = New [Link]("Times new Roman", 14, [Link])
[Link] = True
[Link](txt2)
btnl = New [Link]
[Link] = True
[Link] = New [Link](90, 130)
[Link] = New [Link](51, 71)
[Link] = 0
[Link] = "Calculate"
[Link] = [Link]
[Link] = New [Link]("times new Roman", 14, [Link])
[Link] = True
[Link](btnl)
AddHandler [Link], AddressOf btn1_Click
End Sub
End Class
OUTPUT:
RESULT:
Data is manipulated in dynamic form.
[Link]
Text Editor using Rich Textbox
DATE
Aim:
To Creating a simple text editor with undo, redo, cut, copy, paste, select all,
find, replace, load file, and save file operations using Visual Studio, [Link],
and RichTextBox involves several steps.
Algorithm:
1. Create a new [Link] Windows Forms Application:
- Open Visual Studio.
- Create a new Windows Forms Application project.
2. **Design the Form:**
- Add a RichTextBox control to the form.
- Add a MenuStrip to the form.
- Add menu items for File (New, Open, Save, Save As, Exit), Edit (Undo,
Redo, Cut, Copy, Paste, Select All), and Search (Find, Replace).
3. **Code the Form:**
- Double-click on the menu items to generate event handlers.
- In the form code, declare variables for tracking file path, current text, etc.
- Implement File menu item handlers for New, Open, Save, Save As, and Exit
operations.
- Implement Edit menu item handlers for Undo, Redo, Cut, Copy, Paste, and
Select All operations.
- Implement Search menu item handlers for Find and Replace operations.
4. **Run the Application:**
- Build and run your application to test the text editor.
Coding:
Public Class Form1
Private filePath As String = ""
Private currentText As String = ""
' File Menu
Private Sub NewToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
filePath = ""
currentText = ""
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
Dim openFileDialog As New OpenFileDialog()
[Link] = "Text Files|*.txt|All Files|*.*"
If [Link]() = [Link] Then
filePath = [Link]
currentText = [Link](filePath)
[Link] = currentText
End If
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
If filePath = "" Then
[Link]()
Else
[Link](filePath, [Link])
currentText = [Link]
End If
End Sub
Private Sub SaveAsToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
Dim saveFileDialog As New SaveFileDialog()
[Link] = "Text Files|*.txt|All Files|*.*"
If [Link]() = [Link] Then
filePath = [Link]
[Link](filePath, [Link])
currentText = [Link]
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
' Edit Menu
Private Sub UndoToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
Private Sub RedoToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
Private Sub CutToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
Private Sub CopyToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
Private Sub PasteToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
Private Sub SelectAllToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
[Link]()
End Sub
' Search Menu
Private Sub FindToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
' Implement Find functionality
End Sub
Private Sub ReplaceToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles [Link]
' Implement Replace functionality
End Sub
End Class
OUTPUT
Result:
Thus the above program was executed successfully.
[Link]
Methods and Properties of Listbox
DATE
Aim
To demonstrate use of methods and properties of listbox
Algorithm:
1. Open Visual Studio or any other VB development environment you are
using.
2. Start a new Windows Forms Application project.
3. Drag and drop a `ListBox` control and three buttons (`btnAdd`,
`btnRemove`, `btnClear`) onto the form.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
[Link]
' Set properties for ListBox
[Link] = New Point(10, 10)
[Link] = New Size(200, 150)
' Set properties for btnAdd
[Link] = "Add Item"
[Link] = New Point(220, 10)
' Set properties for btnRemove
[Link] = "Remove Item"
[Link] = New Point(220, 50)
' Set properties for btnClear
[Link] = "Clear All"
[Link] = New Point(220, 90)
' Add controls to the form
[Link](ListBox1)
[Link](btnAdd)
[Link](btnRemove)
[Link](btnClear)
End Sub
' Event handler for btnAdd
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles
[Link]
Dim newItem As String = InputBox("Enter a new item:", "Add Item")
If Not [Link](newItem) Then
[Link](newItem)
End If
End Sub
' Event handler for btnRemove
Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles
[Link]
If [Link] <> -1 Then
[Link]([Link])
End If
End Sub
' Event handler for btnClear
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles
[Link]
[Link]()
End Sub
End Class
OUTPUT
[Link]
Methods and Properties of Listview
DATE
Aim
To demonstrate use of methods and properties of listView
Algorithm:
1. Open Visual Studio or any other VB development environment.
2. Start a new Windows Forms Application project.
3. Drag and drop a `ListView` control and three buttons (`btnAdd`,
`btnRemove`, `btnClear`) onto the form.
Public Class Form1
Private WithEvents ListView1 As New ListView()
Private WithEvents btnAdd As New Button()
Private WithEvents btnRemove As New Button()
Private WithEvents btnClear As New Button()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
[Link]
' Set properties for ListView
[Link] = New Point(10, 10)
[Link] = New Size(200, 150)
[Link] = [Link]
[Link]("Items", 150)
' Set properties for btnAdd
[Link] = "Add Item"
[Link] = New Point(220, 10)
' Set properties for btnRemove
[Link] = "Remove Item"
[Link] = New Point(220, 50)
' Set properties for btnClear
[Link] = "Clear All"
[Link] = New Point(220, 90)
' Add controls to the form
[Link](ListView1)
[Link](btnAdd)
[Link](btnRemove)
[Link](btnClear)
End Sub
' Event handler for btnAdd
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles
[Link]
Dim newItem As String = InputBox("Enter a new item:", "Add Item")
If Not [Link](newItem) Then
Dim item As New ListViewItem(newItem)
[Link](item)
End If
End Sub
' Event handler for btnRemove
Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles
[Link]
If [Link] > 0 Then
[Link]([Link](0))
End If
End Sub
' Event handler for btnClear
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles
[Link]
[Link]()
End Sub
End Class
OUTPUT
Result:
Hence the program is executed successfully.
[Link]
DATE :
MDI CONTROL
AIM:
To create MDI application having file menu (New, Open, Save, Print, Close) and Format
menu (Font, Forecolor, Backcolor).
ALGORITHM:
[Link] Visual Studio and create a new Windows Forms Application.
2. - Add a `MenuStrip` control to the form.
- Add a `ToolStripMenuItem` for each menu item (`New`, `Open`, `Save`, `Print`, `Close`, `Font`,
`ForeColor`, `BackColor`).
- Set the `Name` property for each menu item (e.g., `mnuNew`, `mnuOpen`,etc.).
- Handle the click events for each menu item to implement their functionality.
3. - Create a new Windows Form (`ChildForm`) to be used as an MDI child form.
- Customize the form as needed for your application.
4. - For simplicity, let’s create a basic screen saver using a timer.
- Add a `Timer` control to the MDI Parent Form.
- Handle the `Tick` event of the timer to update the screen saver.
Public Class Form1
Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
[Link] = ""
End Sub
Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
If [Link] = [Link] Then
[Link] =
[Link]([Link])
End If
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
If [Link] = [Link] Then
[Link]([Link],
[Link], False)
End If
End Sub
Private Sub PrintToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
[Link]()
End Sub
Private Sub CloseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
End
End Sub
Private Sub FontToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
[Link]
If [Link] = [Link] Then
[Link] = [Link]
End If
End Sub
Private Sub ForecoloreToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles [Link]
If [Link] = [Link] Then
[Link] = [Link]
End If
End Sub
End Class
OUTPUT
[Link]
DATE:
EMPLOYEE DETAILS
AIM:
To write a [Link] program for retrieving the employee details with the help of SQL
server.
ALGORITHM:
STEP1: Create an Employee details using SQL server.
STEP2: Activate the SQL connection.
STEP3: Select Data Connection and Right Click then click create New SQL server database.
STEP4: Pick the server name from the dropdown box and give new database name.
STEP5: Goto new instance of Data Connection ->Name.
STEP6: Goto Main Menu , Select data click add new Data Source->Click Database->Next->
New Connection->Give Server Name->Database name, filename->choose right to
Tables->Add new table->Create field names .
PROGRAM:
Imports [Link]
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim ar As SqlDataAdapter
Dim ds As DataSet
Dim dr As SqlDataReader
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
'TODO: This line of code loads data into the '[Link]' table. You can move,
or remove it, as needed.
[Link]([Link])
con = New SqlConnection("Data Source=SYSTEM156\SQLEXPRESS;Initial
Catalog=employee;Integrated Security=True")
[Link]()
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
cmd = New SqlCommand("insert into emp values('" & [Link] & "'," &
[Link] & ",'" & [Link] & "'," & [Link] & "," & [Link] &
"," & [Link] & "," & [Link] & "," & [Link] & ")", con)
[Link]()
'[Link]()
'[Link]()
[Link] = "True"
MsgBox("INSERTED")
[Link]()
[Link]()
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim a As Integer
a = InputBox("Enter the Enum")
cmd = New SqlCommand("Update emp set designation='programmer' where enum =" &
Val(a) & "", con)
[Link]()
MsgBox("UPDATED")
[Link] = "True"
[Link]()
[Link]()
End Sub
Private Sub Button3_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
Dim a As Integer
a = InputBox("enter the enum")
cmd = New SqlCommand("Delete From emp where enum=" & Val(a) & "", con)
[Link] = False
[Link]()
MsgBox("DELETED")
[Link] = "True"
[Link]()
[Link]()
End Sub
Private Sub Button4_Click(ByVal sender As [Link], ByVal e As [Link])
Handles [Link]
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub
Private Sub TextBox8_GotFocus(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
'[Link] = Val([Link]) * 0.3
'[Link] = Val([Link]) * 0.2
'[Link] = Val([Link]) * 0.1
[Link] = Val([Link]) + Val([Link]) + Val([Link])
End Sub
Private Sub TextBox5_GotFocus(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
[Link] = Val([Link]) * 0.3
End Sub
Private Sub TextBox6_GotFocus(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
[Link] = Val([Link]) * 0.2
End Sub
Private Sub TextBox7_GotFocus(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
[Link] = Val([Link]) * 0.1
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As [Link], ByVal e As
[Link]) Handles
[Link]
End Sub
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
[Link] = [Link]
End Sub
End Class
OUTPUT:
RESULT:
Thus the manipulation of the data has been carried over.
[Link]
Employee Registration
DATE :
AIM:
To Create employee registration form to collect details (using radio button, checkbox and other
controls).
ALGORITHM:
Step 1: Create a New [Link] Windows Forms Application
1. Open Visual Studio.
2. Create a new Windows Forms Application project.
Step 2: Design the Form
1. Drag and drop the following controls onto the form:
- TextBox controls for `FirstName`, `LastName`, `Email`, and `Phone`.
- RadioButton controls for `Male` and `Female`.
- CheckBox controls for `Programming`, `Designing`, and `Testing`.
- ComboBox for `Department`.
- DateTimePicker for `DateOfBirth`.
- Button to submit the form.
2. Arrange the controls on the form as needed.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]
[Link]()
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
If [Link] - True Then
[Link] = [Link]
End If
If [Link] - True Then
[Link] = [Link]
End If
If [Link] - True Then
[Link] = [Link]
End If
If [Link] = True Then
[Link] = [Link]
End If
If [Link] = True Then
[Link] = [Link]
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles [Link]
End
End Sub
End Class
OUTPUT
RESULT:
Hence Employee registration is done
[Link]
CANTEEN ORDER
DATE :
Aim:
creating a simple Canteen Order Form in [Link]. This form will use a ListBox to display selected
items and a ComboBox to list available food items.
Algorithm:
Step 1: Create a New [Link] Windows Forms Application
1. Open Visual Studio.
2. Create a new Windows Forms Application project.
3: Design the Form
4. Drag and drop the following controls onto the form:
- ComboBox for listing food items (`cmbFoodItems`).
- TextBox for entering quantity (`txtQuantity`).
- Button to add the selected item to the order (`btnAddToOrder`).
- ListBox to display the selected items (`lstOrder`).
- Button to place the order (`btnPlaceOrder`).
5. Arrange the controls on the form as needed.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
[Link]()
[Link]("Coffee")
[Link]("Tea")
[Link]("Juice")
[Link]("Ice Cream")
[Link]("Idily")
[Link]("Puri")
[Link]("Vada")
[Link]("Pongal")
[Link]("Dosai")
[Link]("Ghee Roast")
[Link]("Masala Roast")
[Link]("Podi Roast")
[Link]("1")
[Link]("2")
[Link]("3")
[Link]("4")
[Link]("5")
[Link]("6")
[Link]("7")
[Link]("8")
[Link]("9")
[Link]("10")
[Link]("11")
[Link]("12")
[Link] = "select from...."
[Link] = "select from...."
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles [Link]
[Link] = [Link] * [Link]
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles [Link]
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles [Link]
[Link]()
End Sub
End Class
OUTPUT
Result :
Hence the Program is executed Successfully.