You are on page 1of 52

Ex .

No : 1 CHECK THE CASE OF THE CHARACTER


Aim:

To accept a character from console & check the case of the character.
Procedure:
1. Open Visual Studio .NET IDE.
2. Choose the File-> New -> Project option to display the New Project dialog box.
3. Give the name of the project.
4. The New form will be displayed.
5. Create the label, button, text boxes in the form & write coding.
6. Save the Solution.
7. Click Build-> Start to run the Program.
Algorithm:
1.
2.
3.
4.

Enter the character in the text box.


Check the Ascii value of the given character.
If the value is 65 90 then display it is uppercase.
If the value is 97 122 then display it is lowercase.

Program:

Public Class Form1


Inherits System.Windows.Forms.Form
Dim n As Integer
Private Sub check_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
n = Asc(TextBox1.Text)
Select Case n
Case n = 65 To 90
MsgBox("UPPER CASE")
Case n = 97 To 122
MsgBox("LOWER CASE")
End Select
End Sub
Private Sub end_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
End
End Sub
End Class

Sample Output:

Result:

Thus the program is prepared & verified.


2

Ex. No: 2 CHECK THE GIVEN CHARACTER IS VOWEL OR NOT


Aim:

To Write a program to accept a character from console & display whether it is vowel or
not.
Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog
Give the name of the project.
The New form will be displayed.
Create the label, button, text boxes in the form & write coding.
Save the Solution. Click Build-> Start to run the Program

box.

Algorithm:
1. Enter the character in the textbox.
2. Check the character whether it is vowel or not.
3. If it is vowel display, the character is vowel.
4. Otherwise display the character is not vowel.
Program:

Public Class Form1


Inherits System.Windows.Forms.Form
Dim s As Char
Private Sub check_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
s = TextBox1.Text
Select Case s
Case "a", "e", "i", "o", "u"
MsgBox("VOWEL")
Case "A", "E", "I", "O", "U"
MsgBox("VOWEL")
Case Else
MsgBox("NOT VOWEL")
End Select
End Sub
Private Sub end_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
End
End Sub
End Class

Sample Output:

Result:

Thus the program is prepared & verified.

Ex. No: 3 CONVERT THE CASE OF THE CHARACTER


Aim:
To write a VB.NET program to accept a character from console & convert the case of the
character.
Procedure:
1. Open Visual Studio .NET IDE.
2. Choose the File-> New -> Project option to display the New Project dialog box.
3. Give the name of the project.
4. The New form will be displayed.
5. Create the label, button, text boxes in the form & write coding.
6. Save the Solution.
7. Click Build-> Start to run the Program.
Algorithm:
1. Enter the string in the text box.
2. Use the functions to convert to lowercase or uppercase.
3. If the given string is uppercase convert to lowercase.
4. If the given string is lowercase convert to uppercase.
Program:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim n As Integer
Private Sub lower_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox2.Text = LCase(TextBox1.Text)
End Sub
Private Sub upper_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
TextBox2.Text = UCase(TextBox1.Text)
End Sub
Private Sub end_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
End
End Sub
End Class

Sample Output:

Output:

Result:

Thus the program is prepared & verified.

Ex. No: 4 IMPLEMENT A MENU BASED TEXT EDITOR WITH PASTE, COPY OPERATION
Aim:

To write a menu based VB.NET program to implement a text editor with cut, copy,
paste, save, close operations.
Procedure:

1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the menu, rich text box in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program.
Algorithm:

1.
2.
3.
4.
5.
6.
7.

Create the menu editor in the form.


Enter the text in the rich text box.
Save menu - Save the text in any filename.
Open menu - load the file in rich text box.
Cut menu select the text & clear the space
Copy menu - copy the selected text.
Paste menu paste the selected text in requested place.

Program:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim s As String
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem6.Click
RichTextBox1.SaveFile("d:\notepad.txt")
End Sub
Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem7.Click
End
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Menuitem3.Click
s = RichTextBox1.SelectedText
RichTextBox1.SelectedText = ""
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Menuitem4.Click
s = RichTextBox1.SelectedText
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Menuitem5.Click
RichTextBox1.SelectedText = s

End Sub
Private Sub MenuItem3_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Menuitem3.Click
RichTextBox1.LoadFile("d:\notepad.txt")
End Sub
End Class

Sample Output:

Output:

Result:

Thus the program is prepared & verified.

10

Ex. No: 5 TO IMPELEMENT A CALCULATOR


Aim:

To write a program to implement a calculator with memory & recall operations.


Procedure:
1. Open Visual Studio .NET IDE.
2. Choose the File-> New -> Project option to display the New Project dialog box.
3. Give the name of the project.
4. The New form will be displayed.
5. Create the label, button, text boxes in the form & write coding.
6. Save the Solution.
7. Click Build-> Start to run the Program.
8. Click the add button to add the values, & Click the subtract button to subtract

Values etc.
Algorithm:
1. Enter the values in the textbox1 & textbox2.
2. Add the textbox1 & textbox2 values & place the result in the textbox3.
3. Do the same way for subtract, multiply & divide.
Program:
Public Class Form1
Dim a, m As Integer
Dim op As Char
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
TextBox1.Text = m
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
TextBox1.AppendText("1")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
TextBox1.AppendText("2")
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
TextBox1.AppendText("3")
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click

11

TextBox1.AppendText("4")
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click
TextBox1.AppendText("5")
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button9.Click
TextBox1.AppendText("6")
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
TextBox1.AppendText("7")
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button11.Click
TextBox1.AppendText("8")
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
TextBox1.AppendText("9")
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button13.Click
TextBox1.AppendText("0")
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button14.Click
a = Val(TextBox1.Text)
op = "+"
TextBox1.Clear()
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button15.Click
a = Val(TextBox1.Text)
op = "-"
TextBox1.Clear()
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button16.Click
a = Val(TextBox1.Text)
op = "*"
TextBox1.Clear()
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button17.Click
a = Val(TextBox1.Text)
op = "/"
TextBox1.Clear()
End Sub

12

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button18.Click
Select Case op
Case "+"
TextBox1.Text = a + Val(TextBox1.Text)
Case "-"
TextBox1.Text = a - Val(TextBox1.Text)
Case "*"
TextBox1.Text = a * Val(TextBox1.Text)
Case "/"
TextBox1.Text = a / Val(TextBox1.Text)
End Select
End Sub
End Class

Sample Output:

Output:

Result:

Thus the program is prepared & verified.

13

Ex. No: 6 TO PICK A DATE FORM CALENDAR & DISPLAY THE DAY, MONTH & YEAR

Aim:
To write a program to pick a date from a calendar control & display the day, month,
year details in separate boxes.
Procedure:
1. Open Visual Studio .NET IDE.
2. Choose the File-> New -> Project option to display the New Project dialog box.
3. Give the name of the project.
4. The New form will be displayed.
5. Create the datetimepicker control label, text boxes in the form & write coding.
6. Save the Solution.
7. Click Build-> Start to run the Program.
Algorithm:
1. Click any values in date time picker control.
2. It will display the day, month & year in appropriate textboxes.
Program:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = DateTimePicker1.Value.Day
TextBox2.Text = DateTimePicker1.Value.Month
TextBox3.Text = DateTimePicker1.Value.Year
End Sub
End Class

14

Sample Output:

Result:

Thus the program is prepared & verified.

15

7. PERFORM TIMER BASED QUIZ QUESTION

Aim:
To Write a VB.Net Program to perform timer based quiz question.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the Labels, Buttons, and Radiobuttons in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program.

Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.

Create the 5 Labels, 3 Buttons, 10 Radio buttons, 5 Group box in the form.
Type Questions in Labels.
Adding two Radio buttons each Group box.
Adding Timer Controls set interval as 15000.
Write the coding.
Click Start Button, Time is starting.
Click the Radio Buttons to correct Answer.
Mark is Greater than 3, Message is displayed Pass.

Program:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim n As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Button2.Show()
Button1.Hide()
Button3.Show()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Button2.Hide()

16

Button3.Hide()
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
If RadioButton1.Checked = True Then
n=1
End If
If RadioButton4.Checked = True Then
n=n+1
End If
If RadioButton5.Checked = True Then
n=n+1
End If
If RadioButton8.Checked = True Then
n=n+1
End If
If RadioButton10.Checked = True Then
17

n=n+1
End If
If n >= 3 Then
MsgBox("Pass")
Else
MsgBox("Fail")
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Timer1.Tick
Timer1.Start()
If RadioButton1.Checked = True Then
n=1
End If

If RadioButton4.Checked = True Then


n=n+1
End If
18

If RadioButton5.Checked = True Then


n=n+1
End If
If RadioButton8.Checked = True Then
n=n+1
End If
If RadioButton10.Checked = True Then
n=n+1
End If

If Timer1.Interval = 15000 Then


MsgBox("Time is Elapsed")
If n >= 3 Then
MsgBox("Pass")
Else
MsgBox("Fail")
End If
End
End If
End Sub
End Class

Result:
Thus the program is prepared and verified.

19

8. TO IMPELEMENT A COMMON DIALOG BOX


Aim:
To write a program to implement File, Directory and Directory Controls in a common dialog
box.

Procedure:
1.
2.
3.
4.
5.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the MainMenu,OpenFileMenu,SaveFileMenu,FontDialog,ColorDialog in the form
& write coding.
6. Save the Solution.
7. Click Build-> Start to run the Program.

Algorithm:
1.
2.
3.
4.
5.

Click the File Menu .


Click open, text file is open.
Click save, the file is saved.
Click SelectedFont, Font style is changed.
Click SelectedColor, FontColor is changed.
.

Program:
Imports System.IO
Imports System.IO.StreamWriter
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem4.Click
Try
With FontDialog1
.Font = RichTextBox1.Font
.Color = RichTextBox1.ForeColor
If .ShowDialog = DialogResult.OK Then
setFont()
End If

20

End With
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub
Private Sub setFont()
Try
With FontDialog1
RichTextBox1.Font = .Font
If .ShowColor Then
RichTextBox1.ForeColor = .Color
End If
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
RichTextBox1.Text = " "
End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MenuItem2.Click
21

Dim FileName As String


Dim sr As System.IO.StreamReader
Try
With OpenFileDialog1
.Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
sr = New System.IO.StreamReader(.OpenFile)
RichTextBox1.Text = sr.ReadToEnd()
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (sr Is Nothing) Then
sr.Close()
End If
End Try
End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MenuItem3.Click
Dim FileName As String
Dim sw As System.IO.StreamWriter
Try
With SaveFileDialog1
.FileName = FileName
.Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
22

FileName = .FileName
sw = New System.IO.StreamWriter("FileName")
sw.Write(RichTextBox1.Text)
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (sw Is Nothing) Then
sw.Close()
End If
End Try
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MenuItem5.Click
Static CustomColors() As Integer = {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)}
Try
With ColorDialog1
.Color = RichTextBox1.ForeColor
.CustomColors = CustomColors
If .ShowDialog() = DialogResult.OK Then
RichTextBox1.ForeColor = .Color
CustomColors = .CustomColors
End If
ColorDialog1.Reset()
End With
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub

End Class

Result:
Thus the program is prepared and verified.
23

9. TO STORE THE DETAILS OF STUDENTS USING ADO.NET


Aim:
To develop a database application using ADO.NET to store the details of students.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the label, button, text boxes in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program
8. Create database & Table in the SQL server & store the student details through the
form.

Algorithm:
1. To store the student details using insert command .
2. Execute the insert command.
3. Now the data will be stored in the table.
Program:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
End
End Sub
Private Sub store_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
store.Click
Dim cnn As New SqlConnection
Dim str As String
Dim cmd As New SqlCommand

24

tr = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"


cnn = New SqlConnection(str)
Dim rows As Integer
Dim cmdinsert As SqlCommand
cmdinsert = New System.Data.SqlClient.SqlCommand("insert into studs(num,nam,dept)
values('" & Val(id_txt.Text) & "','" & name_txt.Text & " ',' " & dept.Text & " ')")
MsgBox("ok")
cmdinsert.Connection = cnn
cnn.Open()
cmdinsert.ExecuteNonQuery()
MsgBox("Record is Inserted")
cnn.Close()

End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
End Sub
End Class

25

Result:
Thus the program is prepared & verified.

26

10. TO INSERT, UPDATE & DELETE THE DETAILS OF STUDENTS USING ADO.NET
Aim:
To develop a database application using ADO.NET to insert, update & delete operations.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the label, button, text boxes in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program
8. Create database & Table in the SQL server & insert, update & delete the student details
through the form.

Algorithm:
1.
2.
3.
4.
5.

To add the student details using insert command .


Execute the insert command.
Now the data will be stored in the table.
Using update command we can update the datas.
Using delete command we can delete the records.

Program:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub insert_button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles insert_button.Click
Dim cnn As New SqlConnection
Dim str As String
Dim cmd As New SqlCommand

27

str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"


cnn = New SqlConnection(str)
Dim rows As Integer
Dim cmdinsert As SqlCommand
cmdinsert = New System.Data.SqlClient.SqlCommand("insert into studs(num,nam,dept)
values('" & Val(id_txt.Text) & "','" & name_txt.Text & " ',' " & dept.Text & " ')")
MsgBox("ok")
cmdinsert.Connection = cnn
cnn.Open()
cmdinsert.ExecuteNonQuery()
MsgBox("Record is Inserted")
cnn.Close()
End Sub
Private Sub update_button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles update_button.Click
Dim cnn As New SqlConnection
Dim str As String
Dim cmd As New SqlCommand
str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"
cnn = New SqlConnection(str)
Dim rows As Integer
Dim cmdupdate As SqlCommand
cmdupdate = New System.Data.SqlClient.SqlCommand("update studs set nam='" &
name_txt.Text & " ',dept=' " & dept.Text & " ' where num ='" & Val(id_txt.Text) & "'")
MsgBox("ok")
cmdupdate.Connection = cnn
28

cnn.Open()
cmdupdate.ExecuteNonQuery()
MsgBox("Record is updated")
cnn.Close()
End Sub
Private Sub del_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles del_Button.Click
Dim cnn As New SqlConnection
Dim str As String
Dim cmd As New SqlCommand
str = "user id=sa;Data Source = CC2-52;;Initial Catalog = master;Integrated Security=SSPI"
cnn = New SqlConnection(str)

29

Dim rows As Integer


Dim cmddelete As SqlCommand
cmddelete = New System.Data.SqlClient.SqlCommand("delete from studs where num='"
& Val(id_txt.Text) & "'")
MsgBox("ok")
cmddelete.Connection = cnn
cnn.Open()
cmddelete.ExecuteNonQuery()
MsgBox("Record is deleted")
cnn.Close()
End Sub
Private Sub end_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles end_button.Click
End
End Sub
End Class

Result: Thus the program is prepared & verified.


30

11. TO DISPLAY RECORDS USING DATAGRID


Aim:
To develop a database application using dagtagrid to display records.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the data grid in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program
8. Create database & Table in the SQL server.

Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Click serverExplorer & right click Dataconnections .


In servers selcct the suboption sql servers.
Expand the option & click master.
From their select the table name studs.
Drag the table & fix it in the datagrid.
In sqlconnection select provider name, &Data source name.
Connect datasouce in the properties window.
In sql Data adapter right click & config it.
The data set is created.

Program:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11.stu1)
End Sub End Class

Result: Thus the program is prepared & verified

31

32

12. TO ADD , EDIT & MODIFY RECORDS USING DATAGRID


Aim:
To develop a database application using dagtagrid to add , edit & modify records.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the datagrid in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program
8. Create database & Table in the SQL server.

Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Click serverExplorer & right click Dataconnections .


In servers selcct the suboption sql servers.
Expand the option & click master.
From their select the table name studs.
Drag the table & fix it in the datagrid.
In sqlconnection select provider name, &Data source name.
Connect datasouce in the properties window.
In sql Data adapter right click & config it.
The data set is created.

Program:
Imports System.Data.SqlClient
Imports System.Windows.Forms
Imports System.EventArgs
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11.stu1)
End Sub

33

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim con As New SqlClient.SqlConnection
Dim com As New SqlCommand
Dim adap As New SqlDataAdapter
Dim ds As New DataSet
con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =
master;Integrated Security=SSPI")
con.Open()
'com.CommandText = "delete from stu1 where stud_id='datagrid1.currentcell()'"
com.CommandText = "delete from stu1 "
com.Connection = con
com.ExecuteNonQuery()
adap = New SqlDataAdapter("select * from stu1", con)
adap.Fill(ds, "1")
DataGrid1.DataSource = ds.Tables("1")
End Sub
Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As
System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate
Dim con As New SqlConnection
Dim com As New SqlCommand
Dim ds As New DataSet
Dim adap As New SqlDataAdapter
con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =
master;Integrated Security=SSPI")
con.Open()
com.CommandText = "update stu1 set stud_dept='" & DataGrid1.CurrentCell() &
"',stud_name='" & DataGrid1.CurrentCell() & "' where stud_id='" & DataGrid.CurrentCell() & "'"
com.Connection = con
com.ExecuteNonQuery()
adap = New SqlDataAdapter("select * from stu1", con)
adap.Fill(ds, "1")
DataGrid1.DataSource = ds.Tables("1")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Dim con As New SqlClient.SqlConnection
Dim com As New SqlCommand
Dim adap As New SqlDataAdapter
Dim ds As New DataSet
con = New SqlConnection("user id=sa;Data Source = CC2-52;;Initial Catalog =
master;Integrated Security=SSPI")
con.Open()

34

com.CommandText = "insert into stu1 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" +


TextBox3.Text + "')"
com.Connection = con
35

com.ExecuteNonQuery()
adap = New SqlDataAdapter("select * from stu1", con)
adap.Fill(ds, "1")
DataGrid1.DataSource = ds.Tables("1")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
End Class

Result: Thus the program is prepared & verified.

36

37

13. TO CHANGE CASE CONVERSION


Aim:
To Create a Simple ASP.NET page to output text with a form, two html text boxes, an
html button ,and an html <span> element..

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Select ASP.Net webapplication,Give the name of the project.
The New asp.net form will be displayed.
Create the Labels,Buttons,Text boxes n the form & write coding.
Save the Solution.
7. Click Debug-> Start to run the Program

Algorithm:
1.
2.
3.
4.
5.

Create The ASP.Net form and write span details in html form.
Execute ASP.Net form.
Give Lower String in Textbox1
Click the Button
String is Converted into Uppercase

Program:
Html Coding
<span> Uppercase String </span>

ASP.NET Coding
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox2.Text = UCase(TextBox1.Text)
End Sub
End Class

Result:

Thus the program is prepared & verified .

38

39

14. CREATING A WEB CONTROLS


Aim:
To create a web controls to a page with three different controls to the ASP.NET page
for a reserving rooms in Hotel.

Procedure:
1.
2.
3.
4.
5.
6.
7.
8.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Select ASP.Net webapplication; Give the name of the project.
The New asp.net form will be displayed.
Solution Explorer -> right click ->Add -> Add New Item.
Click WebUserControl and save form.
Create the Labels, Buttons, DropDown List Control n the form & write coding.
Save the Solution.
9. Click Build ->Select Build Solution.

Algorithm:
1.
2.
3.
4.

Create The ASP.Net form and Drag Webusercontrols in to form.


Execute ASP.Net form.
Select Room Type and Click Enter Button
Display the room rent.

Program:
WebUserControl Coding:
<%@
Control
Language="vb"
AutoEventWireup="false"
Codebehind="WebUserControl1.ascx.vb"
Inherits="HotelReserved.WebUserControl1"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<P>
<asp:Label id="Label1" runat="server" Font-Bold="True" Font-Names="Arial" FontSize="Larger">Room
Amount</asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

40

</P>
<P>
<asp:Label
runat="server">RoomType</asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

id="Label3"

<asp:DropDownList id="DropDownList1" runat="server">


<asp:ListItem Value="1000">Single</asp:ListItem>
<asp:ListItem Value="2000">Double</asp:ListItem>
<asp:ListItem Value="3000">AC</asp:ListItem>
</asp:DropDownList></P>
<P>
<asp:Button
id="Button1"
runat="server"
Text="Enter"></asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;
<asp:Label id="Label2" runat="server" Width="184px">Hotel</asp:Label></P>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Label2.Text = "Room Rent is :" + DropDownList1.SelectedItem.Value
41

End Sub

Result: Thus the program is prepared & verified.

42

15. DISPLAY THE RECORD IN REPEATER CONTROL


Aim:
To create application for accessing a SQL database by using ADO.Net by connecting
to the SQL Server database and call a stored procedure.You then display the data in a Repeater
control.

Procedure:
1.
2.
3.
4.
5.
6.
7.
8.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Select ASP.Net web application; Give the name of the project.
The New asp.net form will be displayed.
Solution Explorer -> right click ->Add -> Add New Item.
Click Repeater and Place to form.
Click HTML page and write coding .
Save the Solution.
9. Click Build ->Select Build Solution.

Algorithm:
1. Create The ASP.Net form and connect to sql database in form.
2. Execute ASP.Net form.
3. Display the student details.
Program:
HTML CODING:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="sqldatabase.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

43

<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">


<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>&nbsp;</P>
<P>&nbsp;</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;
<asp:label id="Label1" runat="server" Width="264px">Displaying
Student Details</asp:label><asp:repeater id="TitleRepeater" runat="server">
<ItemTemplate>
<table><tr><td rowspan="1">Number</td></tr>
44

<tr><td rowspan="1">Name</td></tr>
<tr><td rowspan="1">department</td></tr>
</table>
</ItemTemplate>
<HeaderTemplate>Title</HeaderTemplate>
<SeparatorTemplate><hr></SeparatorTemplate>
</asp:repeater></P> </form></body>
</HTML>

45

CODING:
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim cn As New SqlConnection("Data Source=CC2-52;database=master;Integrated
Security=SSPI")
cn.Open()
Dim cmd As New SqlCommand("sp1", cn)
Dim ds As New DataSet
cmd.CommandType = CommandType.StoredProcedure
Dim da = New SqlDataAdapter(cmd)
da.Fill(ds)
TitleRepeater.DataSource = ds
TitleRepeater.DataBind()
cn.Close()
End Sub

Result: Thus the program is prepared & verified.

46

47

16. HOTEL MANAGEMENT SYSTEM USING WEBSERVICES


Aim:
To create a web services application for calling a Web service for a hotel named full,
and you call another web service for for a hotel named empty, and retrieve information
regarding room availability..

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Select ASP.Net web Service application; Give the name of the project.
The New asp.net web service form will be displayed. Name as Hotel.
Click Code View and write coding.
Save the Solution.
7. Click Build ->Select Build Solution.

Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.

Create The ASP.Net web service form.


Execute ASP.Net form.
Click Reserve. It is display reservation details.
Click Price.It is display the price of room.
Click Description. It is display the hotel description.
Click Room. It is display the room details
Click Food. It is display foods available in hotel.
End of the program

Program:
Imports System.Web.Services
<System.Web.Services.WebService(Namespace := "http://tempuri.org/HOTEL/Service1")> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function Reserve(ByVal strRoomType1 As String, ByVal strRoomType2 As String, ByVal
dtmStratDate As Date, ByVal dtmEndDate As Date) As Boolean
Dim r1 As String
Dim r2 As String
End Function

48

49

Dim sd As Date
Dim ed As Date
Dim res As Boolean
Return r1 = strRoomType1
Return r2 = strRoomType2
Return sd = dtmStratDate
Return ed = dtmEndDate
<WebMethod()> _
Public Function Price(ByVal RoomType As String) As Double
Dim a As Double
a = RoomType
Select Case a
Case 1
Return 1000
Case 2
Return 2000
Case 3
Return 3000
Case 4
Return 4000
Case 5
Return 10000
End Select
End Function
<WebMethod()> _
Public Function Description() As String
Return "FRIENDS HOTEL,167,MahatmaGandi Street,Anna Salai,Chennai-01.Ph:23456789"
End Function
<WebMethod()> _
Public Function Room() As String
Return "1.Single Room 2.Double Room 3.Single AC Room 4.Double AC Room 5.Hall"
End Function
<WebMethod()> _
Public Function Food() As String
Return "1.Idly 2.Dosai 3.Poori 4.Barotta 5.Pongal"
End Function
End Class

Result: Thus the program is prepared & verified.

50

51

17. CHECK THE NUMBER IS PRIME


Aim:
To accept a number from console & check number is prime or not.

Procedure:
1.
2.
3.
4.
5.
6.

Open Visual Studio .NET IDE.


Choose the File-> New -> Project option to display the New Project dialog box.
Give the name of the project.
The New form will be displayed.
Create the label, button, text boxes in the form & write coding.
Save the Solution.
7. Click Build-> Start to run the Program.

Algorithm:
1. Enter the number in the text box.
2. Click check button.
3. Display the number is prime or not.
Program:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim n As Integer
Dim p As Integer
n = Val(TextBox1.Text)
p=n%2
If p = 0 Then
MsgBox("Prime Number")
Else
MsgBox("Not Prime Number")
End If
End Sub
End Class

Result: Thus the program is prepared & verified.

52