VB - Net Journal DHARM
VB - Net Journal DHARM
SY-BCA A
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()
1
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA
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
VB.NET DHARM
JASOLIYA 2
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA 3
202327027 SY-BCA A
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
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
VB.NET DHARM
JASOLIYA 5
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA 6
202327027 SY-BCA A
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
Button1.Text = ""
Button2.Text = ""
Button3.Text = ""
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
VB.NET DHARM
JASOLIYA
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
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
VB.NET DHARM
JASOLIYA 11
202327027 SY-BCA A
End Sub
End Sub
End Sub
End If
End Sub
VB.NET DHARM
JASOLIYA 13
202327027 SY-BCA A
End If
End Sub
End If
End Sub
= Label5.Font.Style + FontStyle.Strikeout
Label5.Font = New Font(Label5.Font.Name,
Label5.Font.Size, newfs)
End If
End Sub
End Class
Output
-
:
VB.NET DHARM
JASOLIYA 15
202327027 SY-BCA A
End Sub
End Sub
VB.NET DHARM
JASOLIYA 16
202327027 SY-BCA A
End Sub
Else
MessageBox.Show("please enter numeric value")
Exit Sub
End If
TextBox3.Text = (n1 - n2).ToString()
End Sub
End Sub
VB.NET DHARM
JASOLIYA 17
202327027 SY-BCA A
End Sub
End Sub
End Class
Output :-
VB.NET DHARM
JASOLIYA 18
202327027 SY-BCA A
Output :-
VB.NET DHARM
JASOLIYA 19
202327027 SY-BCA A
→.
Public Class fifth
VB.NET DHARM
JASOLIYA 21
202327027 SY-BCA A
RichTextBox1.SaveFile("E:\pabitra\vb.net\rtb",RichTextBoxStreamTyp
e.RichText) End Sub
Output :-
VB.NET DHARM
JASOLIYA 22
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA 23
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA 24
202327027 SY-BCA A
DateTimePicker1.Value.Date)
com.Parameters.AddWithValue("@pcourse", TextBox5.Text)
com.Parameters.AddWithValue("@pfees", TextBox6.Text)
com.ExecuteNonQuery() con.Close()
MsgBox("updated successfully")
End Sub
VB.NET DHARM
JASOLIYA 25
202327027 SY-BCA A
End Sub
VB.NET DHARM
JASOLIYA 26
202327027 SY-BCA A
da.Fill(ds)
con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
End Class
Output
-
:
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
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
VB.NET DHARM
JASOLIYA 28
202327027 SY-BCA A
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)
End Sub
VB.NET DHARM
JASOLIYA 29
202327027 SY-BCA A
Output
-
:
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
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 32
202327027 SY-BCA A
End Sub
End Sub
End Class
VB.NET DHARM
JASOLIYA 33
202327027 SY-BCA A
Output
-
:
VB.NET DHARM
JASOLIYA 34
202327027 SY-BCA A
VB.NET DHARM
JASOLIYA 35
202327027 SY-BCA A
Output:-
Insert item:-
Imports System.Data
Imports System.Data.OleDb
VB.NET DHARM
JASOLIYA 36
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
If TextBox1.Text = "" Then
VB.NET DHARM
JASOLIYA 37
202327027 SY-BCA A
Output:-
Imports System.Data
VB.NET DHARM
JASOLIYA 38
202327027 SY-BCA A
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
VB.NET DHARM
JASOLIYA 39
202327027 SY-BCA A
Output:-
Imports System.Data.OleDb
End Sub
End Class
VB.NET DHARM
JASOLIYA 40
202327027 SY-BCA A
Output:-
VB.NET DHARM
JASOLIYA 41
202327027 SY-BCA A
Imports System.Data.OleDb
End Sub
da.Fill(ds) con.Close()
con.ConnectionString = strcon
VB.NET DHARM
JASOLIYA 42
202327027 SY-BCA A
da.Fill(ds) con.Close()
DataGridView1.DataSource = ds.Tables(0)
End Sub
End Class
VB.NET DHARM
JASOLIYA 43
202327027 SY-BCA A
Output:-
Account Details:-
Imports System.Data
Imports System.Data.OleDb
com.Parameters.AddWithValue("@inpbalance",
TextBox3.Text) com.ExecuteNonQuery() con.Close()
VB.NET DHARM
JASOLIYA 44
202327027 SY-BCA A
MsgBox("Record Inserted")
End Sub
End Sub
TextBox1.Text =
DataGridView1.Rows(e.RowIndex).Cells("acc_no").Value
TextBox2.Text =
DataGridView1.Rows(e.RowIndex).Cells("cust_name").Value
TextBox3.Text =
VB.NET DHARM
JASOLIYA 45
202327027 SY-BCA A
DataGridView1.Rows(e.RowIndex).Cells("balance").Value
End Sub
End Sub
con.Close()
MsgBox("Record Deleted")
End Sub
VB.NET DHARM
JASOLIYA 46
202327027 SY-BCA A
End Class
Output:-
Transaction Details:-
Imports System.Data
Imports System.Data.OleDb
ComboBox1.DisplayMember = "cust_name"
ComboBox1.ValueMember = "acc_no"
ComboBox1.DataSource = ds.Tables(0)
End Sub
MsgBox("Record Inserted")
End Sub
VB.NET DHARM
JASOLIYA 48
202327027 SY-BCA A
DataGridView1.DataSource = ds.Tables(0)
End Sub
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
MsgBox("Record Updated")
End Sub
End Sub
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
VB.NET DHARM
JASOLIYA 51
202327027 SY-BCA A
Output:-
VB.NET DHARM
JASOLIYA 52