You are on page 1of 15

MITS Science, Arts and Commerce College,

Raniya Bera, Jadan (Pali) Rajasthan PIN-306401

Department of Computer
Science

LABORATORY MANUAL

FOR

BCA-207 Vb.Net LAB BCA.( IIYEAR)

Prepared By:
Ms. Alisha Jain
Assistant Professor
(Department of Computer Science Application)
INDEX
S.N Practical’s Name Date Remark
o
1 Design a form using listbox and textbox and perform
following operation- Add, Delete and Remove items.
2 Design a MDI Form.

3 Design a form using checkbox and radiobutton and


display the text of selected checkbox and radiobutton.
4 Design a form using Timer Control.
5 Design a simple Text editor to perform cut , copy and
paste operations.
6 create a basic text editor using open file dialog.
7 Design a form using Textbox and Horizontal scrollbar
and change the background color of the textbox as
scrollbar scrolls.
8 Create the database "employee.mdb" in MS-Access
and establish the connection to employee.mdb and
show the data using data grid view.
9 Design a simple calculator to perform Add,
Subtract, Multiply and division operations.
Q.1 Design a form using listbox and textbox and perform following operation- Add, Delete and
Remove items.
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


ListBox1.Items.Add(TextBox1.Text)
TextBox1.Clear()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


ListBox1.Sorted = True
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


ListBox1.Items.Clear()
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


ListBox1.Items.Remove(ListBox1.SelectedItem.ToString)
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


Label2.Text = ListBox1.Items.Count
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


ListBox1.Items.Add("Japan")
ListBox1.Items.Add("London")
ListBox1.Items.Add("Laddakh")
ListBox1.Items.Add("Kashmir")
ListBox1.Items.Add("Paris")
ListBox1.Items.Add("Disneyland")
ListBox1.Items.Add("Los Angels")
ListBox1.Items.Add("NewYork")
ListBox1.Items.Add("England")
ListBox1.Items.Add("UK")
ListBox1.Items.Add("USA")
End Sub

Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles


LinkLabel1.LinkClicked
'LinkLabel1.LinkVisited = True
System.Diagnostics.Process.Start("https://www.google.com")
End Sub
End Class
Q.2 Design a MDI Form.

Form 1

Public Class Form1

Private Sub FeedbackFormToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


FeedbackFormToolStripMenuItem.Click
Label1.Visible = False
Dim fm2 As New Form2
fm2.IsMdiChild = Me
fm2.Show()
End Sub

Private Sub WelcomeFormToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


WelcomeFormToolStripMenuItem.Click
Label1.Visible = False
Dim fm3 As New Form3
fm3.MdiParent = Me
fm3.Show()
End Sub
End Class

Form 2

Public Class Form2


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("Successfully Submit The feedback Form")

End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Dispose()
End Sub
End Class

Form 3

Public Class Form3

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim fm4 As New Form4

fm4.Show()
End Sub
End Class

Form 1

Form 2
Form 3

Form 4

Q.3 Design a form using checkbox and radiobutton and display the text of selected checkbox
and radiobutton.

Public Class Form1

Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


If CheckBox1.Checked Then
MsgBox(CheckBox1.Text)
ElseIf CheckBox2.Checked Then
MsgBox("under 20")
ElseIf CheckBox3.Checked Then
MsgBox("under 25")
Else
MsgBox("Please choose an appropriate age")
End If

End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton1.CheckedChanged
GroupBox1.Enabled = False
GroupBox3.Enabled = True
End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton2.CheckedChanged
GroupBox3.Enabled = False
GroupBox1.Enabled = True
End Sub

Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton3.CheckedChanged
GroupBox1.Enabled = False
GroupBox3.Enabled = False
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


Form2.Show()
End Sub
End Class

Q.4 Design a form using Timer Control.


Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


Timer1.Start()

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

If label1.ForeColor = Color.Red Then


label1.ForeColor = Color.Blue
ElseIf label1.ForeColor = Color.Blue Then
label1.ForeColor = Color.Red
End If
TextBox1.Text = TextBox1.Text + 1

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Timer1.Start()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


Timer1.Stop()
End Sub

End Class

Q.5 Design a simple Text editor to perform cut , copy and paste operations.

Form 1
Public Class frmTextEditor

Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


CopyToolStripMenuItem.Click
If TextBox1.SelectionLength > 0 Then
Clipboard.SetText(TextBox1.SelectedText)
End If
End Sub

Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


CutToolStripMenuItem.Click

Clipboard.SetText(TextBox1.SelectedText)

TextBox1.SelectedText = ""
End Sub

Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


PasteToolStripMenuItem.Click
If Clipboard.ContainsText Then
TextBox1.SelectedText = Clipboard.GetText
End If
End Sub

Private Sub UppercaseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


UppercaseToolStripMenuItem.Click
TextBox1.SelectedText = TextBox1.SelectedText.ToUpper
End Sub

Private Sub LowercaseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


LowercaseToolStripMenuItem.Click
TextBox1.SelectedText = TextBox1.SelectedText.ToLower
End Sub

Private Sub FindReplaceToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles


FindReplaceToolStripMenuItem1.Click
frmfind.Show()
End Sub

Private Sub frmTextEditor_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub OpenFileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


OpenFileToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
'Dim path As String
'path = OpenFileDialog1.FileName
TextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End Sub

Private Sub OpenImageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


OpenImageToolStripMenuItem.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If

End Sub
End Class

Form 2
Public Class frmfind

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnfind.Click

Dim selStart As Integer


If chkcase.Checked = True Then
selStart = frmTextEditor.TextBox1.Text.IndexOf(searchWord.Text, StringComparison.Ordinal)
Else
selStart = frmTextEditor.TextBox1.Text.IndexOf(searchWord.Text,
StringComparison.OrdinalIgnoreCase)
End If

If selStart = -1 Then
MsgBox("Can't find word")
Exit Sub
End If

frmTextEditor.TextBox1.Select(selStart, searchWord.Text.Length)

btnfindnxt.Enabled = True
btnreplace.Enabled = True
Btnreplaceall.Enabled = True
frmTextEditor.TextBox1.ScrollToCaret()

End Sub

Private Sub btnfindnxt_Click(sender As Object, e As EventArgs) Handles btnfindnxt.Click


Dim selStart As Integer
If chkcase.Checked = True Then
selStart = frmTextEditor.TextBox1.Text.IndexOf(searchWord.Text, StringComparison.Ordinal)
Else
selStart = frmTextEditor.TextBox1.Text.IndexOf(searchWord.Text,
StringComparison.OrdinalIgnoreCase)
End If

If selStart = -1 Then
MsgBox("Can't find word")
Exit Sub
End If

selStart = frmTextEditor.TextBox1.Text.IndexOf(searchWord.Text,
frmTextEditor.TextBox1.SelectionStart + 1, StringComparison.Ordinal)
frmTextEditor.TextBox1.Select(selStart, searchWord.Text.Length)
End Sub
Private Sub btnreplace_Click(sender As Object, e As EventArgs) Handles btnreplace.Click
If frmTextEditor.TextBox1.SelectedText <> "" Then
frmTextEditor.TextBox1.SelectedText = Replacewith.Text
End If
End Sub

Private Sub Btnreplaceall_Click(sender As Object, e As EventArgs) Handles Btnreplaceall.Click


frmTextEditor.TextBox1.Text = frmTextEditor.TextBox1.Text.Replace(searchWord.Text,
Replacewith.Text)
End Sub
End Class

Q.6 Create a basic text editor using open file dialog.

Public Class frmTextEditor

Private Sub OpenFileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


OpenFileToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
TextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End Sub

Private Sub OpenImageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


OpenImageToolStripMenuItem.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End If

End Sub
End Class

Q.7 Design a form using textbox and horizontal scrollbar and change the background color
of the textbox as scrollbar is scroll.
Public Class Form2

Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar1.Scroll


TextBox1.BackColor = Color.FromArgb(100, HScrollBar1.Value, 0)
End Sub

End Class
Q.8 Create a database in ms-access.
Create a table and perform the following tasks.
Task to be performed
• Establish the connection to employee.mdb
• Display the first record of emp on TextBoxes used on form.
• Display all the records on DataGridView control.

Public Class Form1

Private Sub EmployeeBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)


Me.Validate()
Me.EmployeeBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Database1DataSet)

End Sub

Private Sub EmployeeBindingNavigatorSaveItem_Click_1(sender As Object, e As EventArgs) Handles


EmployeeBindingNavigatorSaveItem.Click
Me.Validate()
Me.EmployeeBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Database1DataSet)

End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet.employee' table. You can move, or
remove it, as needed.
Me.EmployeeTableAdapter.Fill(Me.Database1DataSet.employee)

End Sub

End Class
MS-ACCESS TABLE

employee
ID ename m_no
1 Alisha 89698678
2 diya 56476687
3 kavita 897686786
4 mukesh 785786768

Q.9 Design a simple calculator to perform Add, Subtract, Multiply and division operations.

Program:

Private Sub Command1_Click()


Dim ans, n1, n2 As Integer
n1 = Val(txt1.Text)
n2 = Val(txt2.Text)
ans = n1 + n2
txtans.Text = ans
End Sub

Private Sub Command2_Click()


Dim ans, n1, n2 As Integer
n1 = Val(txt1.Text)
n2 = Val(txt2.Text)
ans = n1 - n2
txtans.Text = ans
End Sub

Private Sub Command3_Click()


Dim ans, n1, n2 As Integer
n1 = Val(txt1.Text)
n2 = Val(txt2.Text)
ans = n1 * n2
txtans.Text = ans
End Sub

Private Sub Command4_Click()


Dim ans, n1, n2 As Integer
n1 = Val(txt1.Text)
n2 = Val(txt2.Text)

ans = n1 / n2
txtans.Text = ans
End Sub

Private Sub Command6_Click()


txt1.Text = ""
txt2.Text = ""
txtans.Text = ""
End Sub

You might also like