202327027 SY-BCA A
1. Develop Tic-Tac-Toe application.
→
Public Class Form1
Dim checkforXorO As Boolean = False
Dim addonetoscore = 0
Sub buttonsEnabledfalse()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False Button5.Enabled =
False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
End Sub
Sub checkforwin()
If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
Button1.BackColor = Color.Black
Button2.BackColor = Color.Black
Button3.BackColor = Color.Black MessageBox.Show("winner is player
X", "tic-tac-toe", MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text)
Label2.Text = Convert.ToString(addonetoscore + 1)
ButtonsEnabledfalse()
VB.NET DHARM JASOLIYA 1
202327027 SY-BCA A
End If
If Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
Button4.BackColor = Color.Black Button5.BackColor =
Color.Black
Button6.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button7.Text = "X" And Button8.Text = "X" And Button9.Text =
"X" Then
Button7.BackColor = Color.Black
Button8.BackColor = Color.Black
Button9.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information) addonetoscore =
Convert.ToInt64(Label2.Text)
Label2.Text = Convert.ToString(addonetoscore + 1)
buttonsEnabledfalse()
End If
If Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
Button1.BackColor = Color.Black
Button4.BackColor = Color.Black
Button7.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
VB.NET DHARM JASOLIYA 2
202327027 SY-BCA A
End If
If Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
Button2.BackColor = Color.Black
Button5.BackColor = Color.Black
Button8.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
Button3.BackColor = Color.Black
Button6.BackColor = Color.Black
Button9.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
Button1.BackColor = Color.Black
Button5.BackColor = Color.Black
Button9.BackColor = Color.Black
MessageBox.Show("winner is player X", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
VB.NET DHARM JASOLIYA 3
202327027 SY-BCA A
If Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
Button3.BackColor = Color.Black Button5.BackColor =
Color.Black
Button7.BackColor = Color.Black MessageBox.Show("winner is player
X", "tic-tac-toe", MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label2.Text) Label2.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
'O combination'
If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
Button1.BackColor = Color.Black
Button2.BackColor = Color.Black
Button3.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
Button4.BackColor = Color.Black Button5.BackColor =
Color.Black
Button6.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information) addonetoscore =
Convert.ToInt64(Label3.Text) Label3.Text = Convert.ToString(addonetoscore + 1)
buttonsEnabledfalse()
End If
If Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
Button7.BackColor = Color.Black
VB.NET DHARM JASOLIYA 4
202327027 SY-BCA A
Button8.BackColor = Color.Black
Button9.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
Button1.BackColor = Color.Black
Button4.BackColor = Color.Black
Button7.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
Button2.BackColor = Color.Black
Button5.BackColor = Color.Black
Button8.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
Button3.BackColor = Color.Black
Button6.BackColor = Color.Black
VB.NET DHARM JASOLIYA 5
202327027 SY-BCA A
Button9.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
Button1.BackColor = Color.Black
Button5.BackColor = Color.Black
Button9.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
If Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
Button3.BackColor = Color.Black Button5.BackColor =
Color.Black
Button7.BackColor = Color.Black
MessageBox.Show("winner is player O", "tic-tac-toe",
MessageBoxButtons.OK, MessageBoxIcon.Information)
addonetoscore = Convert.ToInt64(Label3.Text) Label3.Text =
Convert.ToString(addonetoscore + 1) buttonsEnabledfalse()
End If
End Sub
Private Sub button_click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button9.Click, Button8.Click,
VB.NET DHARM JASOLIYA 6
202327027 SY-BCA A
Button7.Click, Button6.Click, Button5.Click, Button4.Click, Button3.Click,
Button2.Click, Button1.Click
Dim b As Button = sender If
checkforXorO = False Then
b.Text = "X"
checkforXorO = True
Else
b.Text = "O"
checkforXorO = False End If
checkforwin()
b.Enabled = False
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True Button6.Enabled =
True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
VB.NET DHARM JASOLIYA 7
202327027 SY-BCA A
Button4.Text = ""
VB.NET DHARM JASOLIYA 8
202327027 SY-BCA A
Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
Button1.BackColor = Color.White
Button2.BackColor = Color.White
Button3.BackColor = Color.White
Button4.BackColor = Color.White
Button5.BackColor = Color.White Button6.BackColor =
Color.White
Button7.BackColor = Color.White
Button8.BackColor = Color.White
Button9.BackColor = Color.White
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button11.Click
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True Button7.Enabled =
True Button8.Enabled = True
Button9.Enabled = True
VB.NET DHARM JASOLIYA 9
202327027 SY-BCA A
Button1.Text = ""
Button2.Text = ""
Button3.Text = "" Button4.Text
= "" Button5.Text = ""
Button6.Text = ""
Button7.Text = ""
Button8.Text = ""
Button9.Text = ""
Button1.BackColor = Color.White
Button2.BackColor = Color.White
Button3.BackColor = Color.White
Button4.BackColor = Color.White Button5.BackColor =
Color.White Button6.BackColor = Color.White
Button7.BackColor = Color.White Button8.BackColor =
Color.White
Button9.BackColor = Color.White Label2.Text = "0"
Label3.Text = "0"
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
Dim checkforexit As DialogResult =
MessageBox.Show("conform if you want ot exit", "tic-tac-toe",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If checkforexit = DialogResult.Yes Then
Application.Exit()
VB.NET DHARM JASOLIYA 10
202327027 SY-BCA A
End If
End Sub
End Class
Output :-
2. Display value from Text box, Combo box, List box, radio buttoncheck box and
display image on picture box on button click event in message box.
→
Public Class second
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
VB.NET DHARM JASOLIYA 11
202327027 SY-BCA A
MsgBox("textbox value: " & TextBox1.Text & Chr(13) & "combobox value: " &
ComboBox1.SelectedItem & Chr(13) & "listbox value: " & ListBox1.SelectedItem)
PictureBox1.Image = Image.FromFile("E:\pabitra\car.jpeg")
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton1.CheckedChanged
GroupBox1.BackColor = Color.Black
GroupBox1.ForeColor = Color.White
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As
VB.NET DHARM JASOLIYA 12
202327027 SY-BCA A
System.Object, ByVal e As System.EventArgs) Handles
RadioButton2.CheckedChanged
GroupBox1.BackColor = Color.Red
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton3.CheckedChanged
GroupBox1.BackColor = Color.Green
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CheckBox1.CheckedChanged
Dim newfs As FontStyle
If CheckBox1.Checked = True Then newfs =
Label5.Font.Style + FontStyle.Bold
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
ElseIf CheckBox1.Checked = False Then newfs
= Label5.Font.Style - FontStyle.Bold
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CheckBox2.CheckedChanged
Dim newfs As FontStyle
If CheckBox2.Checked = True Then
VB.NET DHARM JASOLIYA 13
202327027 SY-BCA A
newfs = Label5.Font.Style + FontStyle.Italic
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
ElseIf CheckBox2.Checked = False Then newfs
= Label5.Font.Style - FontStyle.Italic
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
End If
End Sub
Private Sub CheckBox4_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CheckBox4.CheckedChanged
Dim newfs As FontStyle
If CheckBox4.Checked = True Then
newfs = Label5.Font.Style + FontStyle.Underline
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
ElseIf CheckBox4.Checked = False Then newfs =
Label5.Font.Style - FontStyle.Underline
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CheckBox3.CheckedChanged
Dim newfs As FontStyle
If CheckBox3.Checked = True Then
newfs = Label5.Font.Style + FontStyle.Strikeout
VB.NET DHARM JASOLIYA 14
202327027 SY-BCA A
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
ElseIf CheckBox3.Checked = False Then newfs =
Label5.Font.Style - FontStyle.Strikeout
Label5.Font = New Font(Label5.Font.Name, Label5.Font.Size, newfs)
End If
End Sub
End Class
Output :-
3. Develop a simple calculator application.
→
Public Class Form1
Dim n1 As Double
VB.NET DHARM JASOLIYA 15
202327027 SY-BCA A
Dim n2 As Double
Private Sub TextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then n1 =
CDbl(TextBox1.Text) n2 = CDbl(TextBox2.Text)
Else
MessageBox.Show("please enter numeric value")
Exit Sub
End If
TextBox3.Text = (n1 + n2).ToString()
End Sub
VB.NET DHARM JASOLIYA 16
202327027 SY-BCA A
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then n1 =
CDbl(TextBox1.Text) n2 = CDbl(TextBox2.Text)
Else
MessageBox.Show("please enter numeric value")
Exit Sub
End If
TextBox3.Text = (n1 - n2).ToString()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then n1 =
CDbl(TextBox1.Text) n2 = CDbl(TextBox2.Text)
Else
MessageBox.Show("please enter numeric value")
Exit Sub
End If
TextBox3.Text = (n1 * n2).ToString()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then n1 =
CDbl(TextBox1.Text)
VB.NET DHARM JASOLIYA 17
202327027 SY-BCA A
n2 = CDbl(TextBox2.Text)
Else
MessageBox.Show("please enter numeric value")
Exit Sub
End If
TextBox3.Text = (n1 / n2).ToString()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
End Class
Output :-
VB.NET DHARM JASOLIYA 18
202327027 SY-BCA A
4. Create windows form application to Display random number in Message box.
→
Public Class fourth
Shared random As New Random
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MsgBox(random.Next())
End Sub
End Class
Output :-
VB.NET DHARM JASOLIYA 19
202327027 SY-BCA A
5. Develop application to use rich text box.
→
Public Class fifth
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RichTextBox1.SelectionIndent -= 10
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button3.Click
If RichTextBox1.SelectionBullet = True Then
RichTextBox1.SelectionBullet = False
Else
RichTextBox1.SelectionBullet = True
End If
End Sub
VB.NET DHARM JASOLIYA 20
202327027 SY-BCA A
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Center End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button5.Click
RichTextBox1.SelectionFont = New Font("arial", 20, FontStyle.Regular)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
RichTextBox1.SelectionColor = Color.Green
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click
RichTextBox1.ZoomFactor += 1.0
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button8.Click
If RichTextBox1.ZoomFactor > 1 Then
RichTextBox1.ZoomFactor -= 1.0
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
VB.NET DHARM JASOLIYA 21
202327027 SY-BCA A
RichTextBox1.SelectionIndent += 10
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button9.Click
RichTextBox1.SaveFile("E:\pabitra\vb.net\rtb",RichTextBoxStreamTyp e.RichText)
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
RichTextBox1.LoadFile("E:\pabitra\vb.net\rtb",
RichTextBoxStreamType.RichText)
End Sub
End Class
Output :-
VB.NET DHARM JASOLIYA 22
202327027 SY-BCA A
6. Create VB.NET application to maintain Student information.
Create following tables :
Tblstuinfo (stuNo, stuName, City, DOB, Course, fees)
Design proper form and make necessary validation.
Provide insert, update, and delete facility for above table. Also provide search
facility on StdNo,
generate report DataGridView
to view details of those Students who are in BCA Course and fee is less than
25000.
→
Imports System.Data
Imports System.Data.OleDb
Public Class sixth
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\student.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
VB.NET DHARM JASOLIYA 23
202327027 SY-BCA A
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "insert into tblstuinfo
values(@pno,@pname,@pcity,@pdob,@pcourse,@pfees)"
com.Parameters.AddWithValue("@pno", TextBox1.Text)
com.Parameters.AddWithValue("@pname", TextBox2.Text)
com.Parameters.AddWithValue("@pcity", TextBox3.Text)
com.Parameters.AddWithValue("@pdob", DateTimePicker1.Value.Date)
com.Parameters.AddWithValue("@pcourse", TextBox5.Text)
com.Parameters.AddWithValue("@pfees", TextBox6.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("inserted successfully")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "update tblstuinfo set
stuNo=@pno,stuName=@pname,city=@pcity,dob=@pdob,course=@pc
ourse,fees=@pfees where stuNo=@pno"
com.Parameters.AddWithValue("@pno", TextBox1.Text)
com.Parameters.AddWithValue("@pname", TextBox2.Text)
com.Parameters.AddWithValue("@pcity", TextBox3.Text)
com.Parameters.AddWithValue("@pdob", DateTimePicker1.Value.Date)
VB.NET DHARM JASOLIYA 24
202327027 SY-BCA A
com.Parameters.AddWithValue("@pcourse", TextBox5.Text)
com.Parameters.AddWithValue("@pfees", TextBox6.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("updated successfully")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "delete from tblstuinfo where stuNo=@pno"
com.Parameters.AddWithValue("@pno", TextBox1.Text)
com.Parameters.AddWithValue("@pname", TextBox2.Text)
com.Parameters.AddWithValue("@pcity", TextBox3.Text)
com.Parameters.AddWithValue("@pdob", DateTimePicker1.Value.Date)
com.Parameters.AddWithValue("@pcourse", TextBox5.Text)
com.Parameters.AddWithValue("@pfees", TextBox6.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("Deleted successfully")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim ds As New DataSet
VB.NET DHARM JASOLIYA 25
202327027 SY-BCA A
Dim da As New OleDbDataAdapter
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "select * from tblstuinfo where stuNo=@pno"
com.Parameters.AddWithValue("@pno", TextBox1.Text)
da.SelectCommand = com
da.Fill(ds)
con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "select * from tblstuinfo where
course='bca' and fees<25000" da.SelectCommand = com
da.Fill(ds)
con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
End Class
VB.NET DHARM JASOLIYA 26
202327027 SY-BCA A
Output :-
7. Create a program that populate combo box with
Movie name. Once user selects particular movie name, display
corresponding details about ticket rate, number of shows of the movie etc.
also delete the record by accepting movie no.
(movie: movieNo, moviename, directore, tickets rate, no_of_shows)
→
Imports System.Data
Imports System.Data.OleDb
Public Class seventh
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\movie.mdb"
Private Sub seventh_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
VB.NET DHARM JASOLIYA 27
202327027 SY-BCA A
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "select * from moviename"
da.SelectCommand = com da.Fill(ds) con.Close()
ComboBox1.DisplayMember = "m_name"
ComboBox1.ValueMember = "m_no"
ComboBox1.DataSource = ds.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "select * from moviename where m_no=@pno"
com.Parameters.AddWithValue("@pno",
ComboBox1.SelectedValue) da.SelectCommand
= com da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
VB.NET DHARM JASOLIYA 28
202327027 SY-BCA A
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim id As String = InputBox("enter id:")
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "delete from moviename where m_no=@pno"
com.Parameters.AddWithValue("@pno", id) com.ExecuteNonQuery()
con.Close()
MsgBox("Deleted successfully")
End Sub
End Class
Output :-
VB.NET DHARM JASOLIYA 29
202327027 SY-BCA A
8. Create VB.NET application maintains Football players record withthe
following database table. Players (name, country, no_of_matches,
no_of_runs).
Perform insert, update, and delete operation on it. Also displaythe player‘s
information according to country wise.
→
Imports System.Data
Imports System.Data.OleDb
Public Class eighth
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\football.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection Dim com As New
OleDbCommand con.ConnectionString = strcon con.Open()
com.Connection = con com.CommandText = "insert into
players(pname,country,no_of_matches,no_of_runs)
values(@inp_name,@inp_country,@nom,@nor)"
com.Parameters.AddWithValue("@inp_name", TextBox1.Text)
com.Parameters.AddWithValue("@inp_country", TextBox2.Text)
com.Parameters.AddWithValue("@nom", TextBox3.Text)
com.Parameters.AddWithValue("@nor", TextBox4.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("Record Inserted Successfully")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
VB.NET DHARM JASOLIYA 30
202327027 SY-BCA A
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "update players set
pname=@inp_name,country=@inp_country,no_of_matches=@nom,no_of_ runs=@nor
where pname=@inp_name or country=@inp_country or no_of_matches=@nom or
no_of_runs=@nor"
com.Parameters.AddWithValue("@inp_name", TextBox1.Text)
com.Parameters.AddWithValue("@inp_country", TextBox2.Text)
com.Parameters.AddWithValue("@nom", TextBox3.Text)
com.Parameters.AddWithValue("@nor", TextBox4.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("Record Updated Successfully")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "delete from players where
pname=@inp_name or country=@inp_country or no_of_matches=@nom or
no_of_runs=@nor"
com.Parameters.AddWithValue("@inp_name", TextBox1.Text)
com.Parameters.AddWithValue("@inp_country", TextBox2.Text)
com.Parameters.AddWithValue("@nom", TextBox3.Text)
com.Parameters.AddWithValue("@nor", TextBox4.Text)
com.ExecuteNonQuery() con.Close()
VB.NET DHARM JASOLIYA 31
202327027 SY-BCA A
MsgBox("Record Deleted Successfully")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
con.ConnectionString = strcon
con.Open() com.Connection = con
com.CommandText = "select
pname,country,no_of_matches,no_of_runs from players group by
country,pname,no_of_matches,no_of_runs" da.SelectCommand = com
da.Fill(ds)
con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
End Sub
End Class
VB.NET DHARM JASOLIYA 32
202327027 SY-BCA A
Output :-
9. Create a VB.NET MDI application that has followingfunctionalities for grocery
stores.
VB.NET DHARM JASOLIYA 33
202327027 SY-BCA A
1. Insert grocery items in
grocery_master_table(item_no, name,MRP, sell price, quantity)
2. Display data in DataGridView and ability to search forspecific item_name.
3. Update, delete operations for updating stock quantity.
4. Listing out stock grocery item in new form.
→
Public Class grocery_store
Private Sub InsertItemToolStripMenuItem_Click_1(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
InsertItemToolStripMenuItem.Click insert.MdiParent = Me
insert.Show()
End Sub
Private Sub DisplayDataToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DisplayDataToolStripMenuItem.Click display.MdiParent = Me
display.Show()
End Sub
Private Sub UpdateAndDeleteToolStripMenuItem_Click_1(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
UpdateAndDeleteToolStripMenuItem.Click ud.MdiParent = Me ud.Show()
End Sub
Private Sub ListOutItemToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListOutItemToolStripMenuItem.Click listout.MdiParent = Me
listout.Show() End Sub
End Class
VB.NET DHARM JASOLIYA 34
202327027 SY-BCA A
Output:-
Insert item:-
Imports System.Data
Imports System.Data.OleDb
Public Class insert
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\grocery.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "insert into grocery_master_table values
(@ino,@iname,@imrp,@isp,@iquantity)" com.Parameters.AddWithValue("@ino",
Val(TextBox1.Text)) com.Parameters.AddWithValue("@iname",
TextBox2.Text) com.Parameters.AddWithValue("@imrp", Val(TextBox3.Text))
com.Parameters.AddWithValue("@isp", Val(TextBox4.Text))
VB.NET DHARM JASOLIYA 35
202327027 SY-BCA A
com.Parameters.AddWithValue("@iquantity", Val(TextBox5.Text))
com.ExecuteNonQuery() con.Close()
MsgBox("inserted succefully")
End Sub
End Class
Output:-
Display data:-
Imports System.Data
Imports System.Data.OleDb
Public Class display
Dim strcon As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\grocery.mdb"
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString =
strcon con.Open() com.Connection = con
VB.NET DHARM JASOLIYA 36
202327027 SY-BCA A
If TextBox1.Text = "" Then
com.CommandText = "select * from grocery_master_table" Else
com.CommandText = "select * from grocery_master_table where
g_name=@iname"
End If
com.Parameters.AddWithValue("@iname", TextBox1.Text)
da.SelectCommand = com da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
End Class
Output:-
Update and Delete:-
VB.NET DHARM JASOLIYA 37
202327027 SY-BCA A
Imports System.Data
Imports System.Data.OleDb
Public Class ud
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\grocery.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim
con As New OleDbConnection Dim com
As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "update grocery_master_table set
item_no=@ino,g_name=@iname,MRP=@imrp,sell_price=@isp,quantity=@iqu antity where
item_no=@ino or g_name=@iname or MRP=@imrp or sell_price=@isp or
quantity=@iquantity" com.Parameters.AddWithValue("@ino", Val(TextBox1.Text))
com.Parameters.AddWithValue("@iname", TextBox2.Text)
com.Parameters.AddWithValue("@imrp", Val(TextBox3.Text))
com.Parameters.AddWithValue("@isp", Val(TextBox4.Text))
com.Parameters.AddWithValue("@iquantity", Val(TextBox5.Text)) com.ExecuteNonQuery()
con.Close()
MsgBox("record updated")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click Dim
con As New OleDbConnection Dim com
As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "delete from grocery_master_table where
item_no=@ino or g_name=@iname or MRP=@imrp or sell_price=@isp or
quantity=@iquantity" com.Parameters.AddWithValue("@ino", Val(TextBox1.Text))
com.Parameters.AddWithValue("@iname", TextBox2.Text)
com.Parameters.AddWithValue("@imrp", Val(TextBox3.Text))
com.Parameters.AddWithValue("@isp", Val(TextBox4.Text))
com.Parameters.AddWithValue("@iquantity", Val(TextBox5.Text))
com.ExecuteNonQuery() con.Close()
MsgBox("record deleted")
End Sub
End Class
VB.NET DHARM JASOLIYA 38
202327027 SY-BCA A
Output:-
List out item:- Imports
System.Data
Imports System.Data.OleDb
Public Class listout
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\grocery.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from grocery_master_table" da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
VB.NET DHARM JASOLIYA 39
202327027 SY-BCA A
End Class
Output:-
10. Develop a VB.NET application to manage bank information with the
following entities:
Account_master (Account_no, Customer_name,
Balance) and Transaction_history (Transaction_id,
Account_no, Transaction_type, Amount, Transaction_date). Implement the
following functionalities:
a. Provide insert, update, delete, and display facilities for managing
account information and transaction history.
b. Display account number, customer name, and balance in ascending
order based on the account balance.
c. Display customer names, their account numbers, and the total balance
customer-wise.
→
Imports System.Data
Imports System.Data.OleDb
Public Class BMS
VB.NET DHARM JASOLIYA 40
202327027 SY-BCA A
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\transaction.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click account.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
transaction.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from account_master order by balance asc"
da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0) End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
con.ConnectionString = strcon
con.Open() com.Connection = con
VB.NET DHARM JASOLIYA 41
202327027 SY-BCA A
com.CommandText = "select cust_name,acc_no,balance as totalbalance from
account_master" da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
End Class
VB.NET DHARM JASOLIYA 42
202327027 SY-BCA A
Output:-
Account Details:-
Imports System.Data
Imports System.Data.OleDb
Public Class account
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\transaction.mdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection Dim
com As New OleDbCommand con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "insert into
account_master(acc_no,cust_name,balance)
values(@inpid,@inpname,@inpbalance)"
com.Parameters.AddWithValue("@inpid",
TextBox1.Text)
com.Parameters.AddWithValue("@inpname",
TextBox2.Text)
VB.NET DHARM JASOLIYA 43
202327027 SY-BCA A
com.Parameters.AddWithValue("@inpbalance",
TextBox3.Text) com.ExecuteNonQuery() con.Close()
MsgBox("Record Inserted")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from account_master" da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from account_master" da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
TextBox1.Text =
VB.NET DHARM JASOLIYA 44
202327027 SY-BCA A
DataGridView1.Rows(e.RowIndex).Cells("acc_no").Value
TextBox2.Text =
DataGridView1.Rows(e.RowIndex).Cells("cust_name").Value
TextBox3.Text =
DataGridView1.Rows(e.RowIndex).Cells("balance").Value
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "update account_master set
cust_name=@inpname,balance=@inpbalance where acc_no=@inpid"
com.Parameters.AddWithValue("@inpname", TextBox2.Text)
com.Parameters.AddWithValue("@inpbalance", TextBox3.Text)
com.Parameters.AddWithValue("@inpid", TextBox1.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("Record Updated")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "delete from account_master where acc_no=@inpid"
VB.NET DHARM JASOLIYA 45
202327027 SY-BCA A
com.Parameters.AddWithValue("@inpid", TextBox1.Text) com.ExecuteNonQuery()
con.Close()
MsgBox("Record Deleted")
End Sub
End Class
Output:-
Transaction Details:-
Imports System.Data
Imports System.Data.OleDb
Public Class transaction
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\pabitra\vb.net\journal\transaction.mdb"
Shared random As New Random
VB.NET DHARM JASOLIYA 46
202327027 SY-BCA A
Private Sub transaction_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from account_master" da.SelectCommand = com
da.Fill(ds) con.Close()
ComboBox1.DisplayMember = "cust_name"
ComboBox1.ValueMember = "acc_no"
ComboBox1.DataSource = ds.Tables(0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con com.CommandText =
"insert into
transaction_history(tra_id,acc_no,tra_type,amount,tra_date)
values(@inpid,@acid,@inptype,@inpamount,@inpdate)"
com.Parameters.AddWithValue("@inpid", random.Next())
com.Parameters.AddWithValue("@acid", ComboBox1.SelectedValue)
com.Parameters.AddWithValue("@inptype", ComboBox2.SelectedItem)
com.Parameters.AddWithValue("@inpamount", TextBox2.Text)
VB.NET DHARM JASOLIYA 47
202327027 SY-BCA A
com.Parameters.AddWithValue("@inpdate",
DateTimePicker1.Value.Date)
com.ExecuteNonQuery() con.Close() callme()
MsgBox("Record Inserted")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from transaction_history" da.SelectCommand = com
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet con.ConnectionString
= strcon con.Open() com.Connection = con
com.CommandText = "select * from transaction_history" da.SelectCommand = com
da.Fill(ds) con.Close()
VB.NET DHARM JASOLIYA 48
202327027 SY-BCA A
DataGridView1.DataSource = ds.Tables(0)
TextBox1.Text =
DataGridView1.Rows(e.RowIndex).Cells("tra_id").Value
ComboBox1.Text =
DataGridView1.Rows(e.RowIndex).Cells("acc_no").Value ComboBox2.Text =
DataGridView1.Rows(e.RowIndex).Cells("tra_type").Value
TextBox2.Text =
DataGridView1.Rows(e.RowIndex).Cells("amount").Value
DateTimePicker1.Text =
DataGridView1.Rows(e.RowIndex).Cells("tra_date").Value
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "update transaction_history set
acc_no=@acid,tra_type=@inptype,amount=@inpamt,tra_date=@inpdat e where
tra_id=@inpid"
com.Parameters.AddWithValue("@acid", ComboBox1.SelectedValue)
com.Parameters.AddWithValue("@inptype", ComboBox2.SelectedItem)
com.Parameters.AddWithValue("@intamt", TextBox2.Text)
com.Parameters.AddWithValue("@inpdate", DateTimePicker1.Value.Date)
com.Parameters.AddWithValue("@tra_id", TextBox1.Text) com.ExecuteNonQuery()
con.Close()
MsgBox("Record Updated")
End Sub
VB.NET DHARM JASOLIYA 49
202327027 SY-BCA A
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
Dim com As New OleDbCommand
con.ConnectionString = strcon con.Open()
com.Connection = con
com.CommandText = "delete from transaction_history where tra_id=@inpid"
com.Parameters.AddWithValue("@inpid", TextBox1.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("Record Deleted")
End Sub
Public Sub callme()
Dim con As New OleDbConnection
Dim com As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet Dim
i As Integer con.ConnectionString =
strcon con.Open()
com.Connection = con
com.CommandText = "select * from transaction_history" da.SelectCommand = com
da.Fill(ds) con.Close()
i = ds.Tables(0).Rows.Count - 1
Dim str As String = ds.Tables(0).Rows(i)("tra_type").ToString If
String.Compare(str, "CREDIT") = 0 Then con.Open() com.Connection = con
com.CommandText = "update account_master set balance=balance+@inpamt
where acc_no=@inpid" com.Parameters.AddWithValue("@inpamt",
VB.NET DHARM JASOLIYA 50
202327027 SY-BCA A
TextBox2.Text) com.Parameters.AddWithValue("@inpid",
ComboBox1.SelectedValue) com.ExecuteNonQuery() con.Close()
ElseIfString.Compare(str, "DEBIT") = 0 Then
con.Open() com.Connection = con
com.CommandText = "update account_master set balance=balance-
@inpamt where acc_no=@inpid"
com.Parameters.AddWithValue("@inpamt", TextBox2.Text)
com.Parameters.AddWithValue("@inpid", ComboBox1.SelectedValue)
com.ExecuteNonQuery()
con.Close()
End If
End Sub
End Class
Output:-
VB.NET DHARM JASOLIYA 51