Professional Documents
Culture Documents
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.
Program:
Sample Output:
Result:
To Write a program to accept a character from console & display whether it is vowel or
not.
Procedure:
1.
2.
3.
4.
5.
6.
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:
Sample Output:
Result:
Sample Output:
Output:
Result:
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.
1.
2.
3.
4.
5.
6.
7.
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:
10
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
12
Sample Output:
Output:
Result:
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:
15
Aim:
To Write a VB.Net Program to perform timer based quiz question.
Procedure:
1.
2.
3.
4.
5.
6.
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
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
Result:
Thus the program is prepared and verified.
19
Procedure:
1.
2.
3.
4.
5.
Algorithm:
1.
2.
3.
4.
5.
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
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
Procedure:
1.
2.
3.
4.
5.
6.
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
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.
Algorithm:
1.
2.
3.
4.
5.
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
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
Procedure:
1.
2.
3.
4.
5.
6.
Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
9.
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
31
32
Procedure:
1.
2.
3.
4.
5.
6.
Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
9.
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
34
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
36
37
Procedure:
1.
2.
3.
4.
5.
6.
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:
38
39
Procedure:
1.
2.
3.
4.
5.
6.
7.
8.
Algorithm:
1.
2.
3.
4.
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>
40
</P>
<P>
<asp:Label
runat="server">RoomType</asp:Label>
id="Label3"
End Sub
42
Procedure:
1.
2.
3.
4.
5.
6.
7.
8.
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
<P> &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
46
47
Procedure:
1.
2.
3.
4.
5.
6.
Algorithm:
1.
2.
3.
4.
5.
6.
7.
8.
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
50
51
Procedure:
1.
2.
3.
4.
5.
6.
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
52