Dot Net Framework
PRACTICAL SLIP
SLIP NO 1
A) Write a [Link] Program to display the numbers continuously in TextBox by
clicking on Button.
Answer :
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles [Link]
[Link] = Second([Link])
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = True
[Link] = 1000
[Link]()
End Sub
End Class
Output :
B) Write a [Link] program to accept the details of Employee (ENO, EName Salary)
and store it into the database and display it on gridview control.
Answer :
Imports System
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from Emp", con)
Dim ds As New DataSet
Dim cmd As New OleDbCommand
Public Function display()
[Link](ds, "Emp")
[Link] = ds
[Link] = "Emp"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into Emp values(" & [Link] & ",'" &
[Link] & "'," & [Link] & ")"
[Link]()
[Link]()
[Link]()
[Link]()
display()
End Sub
End Class
Output :
SLIP NO 2
A) Write a [Link] program to move the Text “Pune University” continuously from Left
to Right and Vice Versa.
Answer :
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles [Link]
If [Link] >= [Link] Then
[Link] = -100
Else
[Link] = [Link] + 10
End If
End Sub
End Class
Output :
B)Write a C#.Net program to create a base class Department and derived classes Sales and
Human Resource. Accept the details of both departments and display them in proper
format.
Answer :
Output :
SLIP NO 3
A) Write a program in C# .Net to create a function for the sum of two numbers.
Answer :
namespace WinFormsApp18
public partial class Form1 : Form
public Form1()
InitializeComponent();
public static int Sum(int a, int b)
return a + b;
private void button1_Click(object sender, EventArgs e){
int a = Convert .ToInt32 ([Link]);
int b = Convert .ToInt32 ([Link]);
int c = Sum (a, b);
[Link] = [Link]();
Output :
B) Write a [Link] program to create teacher table (Tid, TName, subject) Insert the
records (Max: 5). Search record of a teacher whose name is “Seeta” and display result.
Answer :
Imports System
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from teacher", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "teacher")
[Link] = ds
[Link] = "teacher"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into teacher values(" & [Link] & ",'" &
[Link] & "','" & [Link] & "')"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
Private Sub TextBox4_KeyDown(sender As Object,
e As KeyEventArgs) Handles [Link]
[Link]()
Dim adp As New OleDbDataAdapter("select * from teacher Where Name like
'%" & [Link] & "%'", con)
[Link](ds, "search")
[Link] = ds
[Link] = "search"
End Sub
End Class
Output :
SLIP NO 4
A) Design a [Link] form to pick a date from DateTimePicker Control and display day,
month and year in separate text boxes.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = "Year : " & [Link]
[Link] = "Month : " & [Link]
[Link] = "Day : " & [Link]
End Sub
End Class
Output :
B) Create a web application to insert 3 records inside the SQL database table having
following fields ( DeptId, DeptName, EmpName, Salary). Update the salary for any one
employee and increment it to 15% of the present salary. Perform delete operation on
one row of the database table.
Answer :
Output :
SLIP NO 5
A) Write a [Link] program to accept a character from keyboard and check whether it
is vowel or consonant. Also display the case of that character.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
Dim a As Char
Dim str As String
a = [Link]
If ([Link] <= 1) Then
If [Link](a) Then
str = "Upper Case"
Else
str = "Lower Case"
End If
If (a = "a" Or a = "e" Or a = "i" Or a = "o" Or a = "u" Or
a = "A" Or a = "E" Or a = "I" Or a = "O" Or a = "U") Then
[Link]([Link] & " is " & str & " Vowel")
Else
[Link]([Link] & " is " & str & " Consonant")
End If
End If
End Sub
Private Sub TextBox1_Leave(sender As Object,
e As EventArgs) Handles [Link]
Dim a As String
a = [Link]
If ([Link] > 1) Then
[Link] = "Only One Characters Allowed...!"
Else
[Link] = ""
End If
End Sub
End Class
Output :
B) Design a web application form in [Link] having loan amount, interest rate and
duration fields. Calculate the simple interest and perform necessary validation i.e.
Ensures data has been entered for each field. Checking for non-numeric value. Assume
suitable web-form controls and perform necessary validation.
Answer :
Output :
SLIP NO 6
A) Write [Link] program that displays the names of some flowers in two columns.
Bind a label to the RadioButtonList so that when the user selects an option from the list
and clicks on a button, the label displays the flower selected by the user.
Answer :
Output :
B) Write a [Link] program to create movie table (Mv_Name, Release_year,
Director). Insert the records (Max: 5). Delete the records of movies whose release year
is 2022 and display appropriate message in message box.
Answer :
Imports System
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from movie", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "movie")
[Link] = ds
[Link] = "movie"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into movie values('" & [Link] & "'," &
[Link] & ",'" & [Link] & "')"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
Private Sub Button2_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "DELETE FROM movie WHERE Release_year = " &
[Link]
[Link]()
If [Link]() Then
[Link]("Deleted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
End Class
Output :
SLIP NO 7
A) Write a [Link] program to accept a number from the user in a textbox control and
throw an exception if the number is not a perfect number. Assume suitable controls on
the web form.
Answer :
Output :
B) Write a [Link] program to create a table student (Roll No, SName, Class,City).
Insert the records (Max: 5). Update city of students to ‘Pune’ whose city is ‘Mumbai’
and display updated records in GridView.
Answer :
Output :
SLIP NO 8
A) List of employees is available in listbox. Write [Link] application to add
selected or all records from listbox to Textbox (assume multi-line property of textbox is
true).
Answer :
Output :
B) Write a c#.Net program for multiplication of matrices.
Answer :
Output :
SLIP NO 9
A) Write a Menu driven program in C#.Net to perform following functionality:
Addition, Multiplication, Subtraction, Division.
Answer :
namespace WinFormsApp18
public partial class Form1 : Form
public Form1()
{
InitializeComponent();
private void addtionToolStripMenuItem_Click(object sender, EventArgs e)
int a = Convert.ToInt32([Link]);
int b = Convert.ToInt32([Link]);
int c = a+b;
[Link] = "+";
[Link] = [Link]();
private void substractionToolStripMenuItem_Click(object sender, EventArgs
e)
int a = Convert.ToInt32([Link]);
int b = Convert.ToInt32([Link]);
int c = a - b;
[Link] = "-";
[Link] = [Link]();
private void divisonToolStripMenuItem_Click(object sender, EventArgs e)
int a = Convert.ToInt32([Link]);
int b = Convert.ToInt32([Link]);
int c = a / b;
[Link] = "/";
[Link] = [Link]();
private void multiplicationToolStripMenuItem_Click(object sender,
EventArgs e)
int a = Convert.ToInt32([Link]);
int b = Convert.ToInt32([Link]);
int c = a * b;
[Link] = "*";
[Link] = [Link]();
Output :
B) Create an application in [Link] that allows the user to enter a number in the
textbox named "getnum". Check whether the number in the textbox "getnum" is
palindrome or not. Print the message accordingly in the label control named lbldisplay
when the user clicks on the button "check".
Answer :
Output :
SLIP NO 10
A) Write a program that demonstrates the use of primitive data types in C#. The
program should also support the type conversion of :
● Integer to String
● String to Integer
Answer :
namespace WinFormsApp19
public partial class Form1 : Form
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32([Link]);
[Link] = "Before conversion : " + [Link]();
String str = [Link](num);
[Link] = "After conversion: " + [Link]();
private void button2_Click(object sender, EventArgs e)
[Link] = "Before conversion : " + [Link]();
int num = Convert.ToInt32([Link]);
[Link] = "After conversion: " + [Link]();
Output :
B) Write [Link] program to connect to the master database in SQL Server in the
Page_Load event. When the connection is established, the message “Connection has
been established” should be displayed in a label in the form .
Answer :
Output :
SLIP NO 11
A) Write a [Link] program that gets user input such as the user name, mode of
payment, appropriate credit card. After the user enters the appropriate values the
Validation button validates the values entered.
Answer :
Output :
B) Write C# program to make a class named Fruit with a data member to calculate the
number of fruits in a basket. Create two other class named Apples and Mangoes to
calculate the number of apples and mangoes in the basket. Display total number of
fruits in the basket.
Answer :
Output :
SLIP NO 12
A) Write [Link] program that displays a button in green color and it should change
into yellow when the mouse moves over it.
Answer :
Output :
B) Write a [Link] program to create player table (PID, PName, Game,
no_of_matches). Insert records and update number of matches of ‘Rohit Sharma’ and
display result in data grid view.
Answer :
Imports System
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from player", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "player")
[Link] = ds
[Link] = "player"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into player values(" & [Link] & ",'" &
[Link] & "','" & [Link] & "'," & [Link] & ")"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
Private Sub Button2_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "UPDATE player SET no_of_matches = " & [Link]
& " WHERE PName = '" & [Link] & "'"
[Link]()
If [Link]() Then
[Link]("Updated Successfully...!")
End If
[Link]()
[Link]()
[Link]()
display()
End Sub
End Class
Output :
SLIP NO 13
A) Write a [Link] program for blinking an image.
Answer :
Public Class Form1
Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles [Link]
If [Link] Then
[Link] = False
Else
[Link] = True
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
[Link] = True
[Link] = 1000
[Link]()
End Sub
End Class
Output :
B) Write a C# Program to accept and display ‘n’ student’s details such as Roll. No,
Name, marks in three subjects, using class. Display percentage of each student.
Answer :
Output :
SLIP NO 14
A) Write a [Link] program for blinking an image.
Answer :
Public Class Form1
Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles [Link]
If [Link] Then
[Link] = False
Else
[Link] = True
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
[Link] = True
[Link] = 1000
[Link]()
End Sub
End Class
Output :
B) Write a C# Program to accept and display ‘n’ student’s details such as Roll. No,
Name, marks in three subjects, using class. Display percentage of each student.
Answer :
Output :
SLIP NO 15
A) Write [Link] application to create a user control that contains a list of colors. Add
a button to the Web Form which when clicked changes the color of the form to the
color selected from the list.
Answer :
Public Class Form1
Private Sub RedToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub GreenToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub BlueToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
End Class
Output :
B) Write a C#.Net Program to accept and display ‘n’ customer’s details such as
customer_no, Name, address ,itemno, quantity price . Display total price of all item.
Answer :
Output :
SLIP NO 16
A) Write [Link] program to create a user control that receives the user name and
password from the user and validates them. If the user name is "DYP" and the password
is "Pimpri", then the user is authorized, otherwise not.
Answer :
Output :
B) Define a class supplier with fields – sid, name, address, pincode. Write a C#.Net
Program to accept the details of ‘n’ suppliers and display it.
Answer :
Output :
SLIP NO 17
A) Write a C#.Net application to display the vowels from a given String.
Answer :
namespace WinFormsApp21
public partial class Form1 : Form
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
String str = ([Link]);
char[] chars = [Link]();
for (int i = 0; i < [Link]; i++)
switch (chars[i])
case 'A' or 'a':
[Link](chars[i].ToString());
break;
case 'E' or 'e':
[Link](chars[i].ToString());
break;
case 'I' or 'i':
[Link](chars[i].ToString());
break;
case 'O' or 'o':
[Link](chars[i].ToString());
break;
case 'U' or 'u':
[Link](chars[i].ToString());
break;
Output :
B) Write a [Link] program to accept the details of product (PID, PName,
expiry_date, price). Store it into the database and display it on data grid view.
Answer :
Imports System
Imports [Link]
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from product", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "product")
[Link] = ds
[Link] = "product"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into product values(" & [Link] & ",'" &
[Link] & "','" & [Link] & "'," & [Link] & ")"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
End Class
Output :
SLIP NO 18
A) Write a [Link] program to accept a number from user through input box and
display its multiplication table into the list box.
Answer :
Public Class Form1
Dim a As Integer
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
Dim a As Integer
a = [Link]
For b = 1 To 10
[Link](a * b)
Next
[Link]()
End Sub
End Class
Output :
B) Write [Link] program containing the following controls:
• ListBox
• Button
• Image
• Label
The listbox is used to list items available in a store. When the user clicks on an
item in the listbox, its image is displayed in the image control. When the user clicks the
button, the cost of the selected item is displayed in the control.
Answer :
Output :
SLIP NO 19
A) Write a [Link] program to check whether enter string is palindrome or not.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
Dim str, rev As String
str = [Link]
rev = StrReverse(str)
If (str = rev) Then
[Link]("String is Palindrome : " & str)
Else
[Link]("String is Not Palindrome : " & str)
End If
End Sub
End Class
Output :
B) "How is the book [Link] with C# by Wrox publication?"
Give the user three choices :
i)Good ii)Satisfactory iii)Bad.
Provide a VOTE button. After user votes, present the result in percentage using labels
next to the choices.
Answer :
Output :
SLIP NO 20
A) Write a [Link] program to generate Sample Tree View control.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link]("Master")
[Link](0).[Link]("Student Details")
[Link](0).[Link]("Teacher Details")
[Link]("Examination")
[Link](1).[Link]("Internal Exam")
[Link](1).[Link]("External Exam")
[Link](1).[Link]("Practical Exam")
End Sub
End Class
Output :
B) Write a Web application in [Link] that generates the “IndexOutOfRange”
exception when a button is clicked. Instead of displaying the above exception, it
redirects the user to a custom error page. All the above should be done with the trace
for the page being enabled.
Answer :
Output :
SLIP NO 21
A) Write a [Link] program to accept sentences in text box and count the number of
words and display the count in message box.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
Dim str As String
str = [Link]
Dim I, Count As Integer
Dim arr() As Char = [Link]
For I = 0 To [Link] - 1
If arr(I) = " " Then
Count = Count + 1
End If
Next
MsgBox(Count + 1 & " words")
End Sub
End Class
Output :
B) Write [Link] application for the following:
1. Create a table EMP(eno, ename, edesignation, salary, joindate)
2. Insert a Record.
3. Update a record
Answer :
Output :
SLIP NO 22
A) Write a program in C# to create a function to swap the values of two integers.
Answer :
Output :
B) Write a [Link] program to design the following form; it contains the three menus
Color (Red, Blue, and Green), Window (Maximize, Minimize, and Restore) and Exit.
On Selection of any menu or submenu result should affect the form control( for
example if user selected Red color from Color menu back color of form should get
changed to Red and if user selected Maximize from Window Menu then form should
get maximized).
Answer :
Public Class Form1
Private Sub RedToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub GreenToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub BlueToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub MaximizeToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub MiniMToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
Private Sub RestoreToolStripMenuItem_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = [Link]
End Sub
End Class
Output :
SLIP NO 23
A) Write a program in C# to create a function to display the n terms of Fibonacci
sequence.
Answer :
namespace WinFormsApp22
public partial class Form1 : Form
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
{
int a, b=0, c=1, d;
a = Convert.ToInt32([Link]);
[Link](b);
[Link](c);
for (int i = 0; i < a; i++)
d = b + c;
[Link](d);
b = c;
c = d;
Output :
B) Create the application in [Link] that accepts name, password ,age , email id, and
user id. All the information entry is compulsory. Password should be reconfirmed. Age
should be within 21 to 30. Email id should be valid. User id should have at least a
capital letter and digit as well as length should be between 7 and 20 characters.
Answer :
Output :
SLIP NO 24
A) Write a program in C#.Net to create a function to check whether a number is prime or
not.
Answer :
namespace WinFormsApp26
public partial class Form1 : Form
public Form1()
InitializeComponent();
public static String prime(int a)
Boolean isprime = true;
int b = a/2;
for(int i = 2; i <= b; i++)
{
if(a % 2 == 0)
isprime = false;
break;
if (isprime)
return a + " is Prime Number";
else
return a + " is Not Prime Number";
private void button1_Click(object sender, EventArgs e)
[Link](prime(Convert.ToInt32([Link])));
Output :
B) Write a [Link] program to create Author table (aid, aname, book_ name). Insert the
records (Max 5). Delete a record of author who has written “[Link] book” and
display remaining records on the data grid view. (Use MS Access to create db.)
Answer :
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from Author", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "Author")
[Link] = ds
[Link] = "Author"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into Author values(" & [Link] & ",'" &
[Link] & "','" & [Link] & "')"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
Private Sub Button2_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "DELETE FROM Author WHERE book_name='" & [Link]
& "'"
[Link]()
If [Link]() Then
[Link]("Deleted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
End Class
Output :
SLIP NO 25
A) Write a program in C#.Net to create a function to calculate the sum of the individual
digits of a given number.
Answer :
Output :
B) Create a Web Application in [Link] to display all the Empname and Deptid of the
employee from the database using SQL source control and bind it to GridView.
Database fields are(DeptId, DeptName, EmpName, Salary).
Create Table Alter Table Drop Table Type Your DDL Query Here
Answer :
Output :
SLIP NO 26
A). Write a program in C#.Net to create a recursive function to find the factorial of a
given number
Answer :
Output :
B) Write a [Link] program to create a Login Module which adds Username and
Password in the database. Username in the database should be a primary key.
Answer :
Output :
SLIP NO 27
A) Write a program in C#.Net to find the length of a string.
Answer :
namespace WinFormsApp24
public partial class Form1 : Form
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
int a = [Link];
[Link]("Length : " + a);
Output :
B) Create a web application in [Link] which may have a textbox. Now user must type
some data into it, the data he can enter is only 255 characters. After he crosses the limit
then the last word should not by typed and at the same time color of textbox
should be red.
Answer :
Output :
SLIP NO 28
A) Write a program in C#.Net to read n numbers in an array and display it in reverse
order.
Answer :
namespace WinFormsApp23
public partial class Form1 : Form
{
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
[Link]([Link]);
private void button2_Click(object sender, EventArgs e)
[Link]();
for (int i = [Link]-1; i >= 0; i--)
[Link] ([Link][i]);
Output :
B) Write a [Link] program to create a table Patient (PID, PName, Contact No,
Disease). Insert five records into table and display appropriate message in message box.
ENo EName Salary
Answer :
Output :
SLIP NO 29
A) Write a program in C#.Net to separate the individual characters from a String.
Answer :
using System;
class Program {
static void Main(string[] args) {
string inputString = "Hello, world!";
char[] characters = [Link]();
[Link]("Individual characters from the string: ");
foreach (char c in characters) {
[Link](c + " ");
[Link]();
Output :
B) Write a [Link] program to accept the details of customer (CName, Contact No,
Email_id). Store it into the database with proper validation and display appropriate
message by using Message box.
Answer :
Imports [Link]
Public Class CustomerForm
' Database connection string
Dim connectionString As String = "Data
Source=localhost\SQLEXPRESS;Initial Catalog=TestDB;Integrated
Security=True"
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles
[Link]
' Get the customer details from textboxes
Dim cname As String = [Link]()
Dim contactNo As String = [Link]()
Dim email As String = [Link]()
' Validate the inputs
If cname = "" Then
[Link]("Please enter customer name.", "Error",
[Link], [Link])
Return
End If
If contactNo = "" Or Not IsNumeric(contactNo) Then
[Link]("Please enter valid contact number.",
"Error", [Link], [Link])
Return
End If
If email = "" Or Not [Link]("@") Then
[Link]("Please enter valid email address.", "Error",
[Link], [Link])
Return
End If
' Insert the customer details into the database
Using connection As New SqlConnection(connectionString)
Dim query As String = "INSERT INTO Customers (CName,
ContactNo, Email) VALUES (@CName, @ContactNo, @Email)"
Dim command As New SqlCommand(query, connection)
[Link]("@CName", cname)
[Link]("@ContactNo", contactNo)
[Link]("@Email", email)
[Link]()
Dim rowsAffected As Integer = [Link]()
[Link]()
If rowsAffected > 0 Then
[Link]("Customer details saved
successfully.", "Success", [Link], [Link]
on)
Else
[Link]("Failed to save customer
details.", "Error", [Link], [Link])
End If
End Using
End Sub
End Class
Output :
SLIP NO 30
A) Write a [Link] program to design following screen, accept the details from the user. Clicking
on Submit button Net Salary should be calculated and displayed into the Textbox. Display the
Messagebox informing the Name and Net Salary of employee.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = (Int([Link]) + Int([Link]) + Int([Link])
+ Int([Link]) + Int([Link]) + Int([Link]) +
Int([Link]))
[Link] = Int([Link]) + Int([Link]) + Int([Link])
[Link] = [Link] - [Link]
[Link]("Employee Name : " & [Link] & [Link]
& "Total Salary is : " & [Link])
End Sub
Private Sub TextBox2_Leave(sender As Object,
e As EventArgs) Handles [Link]
[Link] = ([Link] * 31) / 100
[Link] = ([Link] * 9) / 100
End Sub
End Class
Output :
B) Write a [Link] program to accept the details Supplier (SupId, SupName, Phone
No, Address) store it into the database and display it.
Answer :
Imports [Link]
Public Class Form1
Dim con As New OleDbConnection("Provider=[Link].12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\[Link]")
Dim adpt As New OleDbDataAdapter("Select * from Supplier", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
[Link](ds, "Supplier")
[Link] = ds
[Link] = "Supplier"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles [Link]
display()
End Sub
Private Sub Button1_Click(sender As Object,
e As EventArgs) Handles [Link]
[Link] = con
[Link] = [Link]
[Link] = "insert into Supplier values(" & [Link] & ",'" &
[Link] & "'," & [Link] & ",'" & [Link] & "')"
[Link]()
If [Link]() Then
[Link]("Inserted Successfully...!")
End If
[Link]()
[Link]()
display()
End Sub
End Class
Output :