Professional Documents
Culture Documents
VB.net (1).docx
VB.net (1).docx
net
A Practical File
Submitted by
Ankit Sharma
(MU16BCA027)
Under the guidance of
this.
and due acknowledgement has been made in the text to all other
Signature: …………
CERTIFICATE OF COMPLETION
Raipur.
The Practical Assignment has been accepted for the partial fulfilment
of BCA program.
grid view
system
and destructor
My Class keyword
1. Develop a windows application to view data in data grid
view
Imports System.Data.OleDb
End Class
2.Develop a windows program to implement timer
Imports System.Data.OleDb
Public Class Form1
Dim connString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Users\Hello\Music\VB.Net\Windows Application\update grid
view\Database3.mdb"
Dim MyConn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim tables As DataTableCollection
Dim source1 As New BindingSource
Dim conn_string As String
Dim my_conn As OleDb.OleDbConnection
Query.ExecuteNonQuery()
MessageBox.Show("Record Inserted")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button4.Click
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
ds = New DataSet
tables = ds.Tables
da = New OleDbDataAdapter("Select * from [data]", MyConn)
'Change items to your database name
da.Fill(ds, "data") 'Change items to your database name
Dim view As New DataView(tables(0))
source1.DataSource = view
DataGridView1.DataSource = view
End Sub
Registration
Public Class Form2
Private Sub Button2_Click(sender As Object, e As EventArgs)
Handles Button2.Click
Me.Hide()
Form1.Show()
End Sub
Conn.ConnectionString = Connstring
Query.Connection = Conn
Conn.Open()
Query.CommandText = "insert into Quiz
Values(@Name,@User_ID,@Password,@Email)"
Query.Parameters.AddWithValue("@Name", TextBox1.Text)
Query.Parameters.AddWithValue("@User_ID", TextBox2.Text)
Query.Parameters.AddWithValue("@Password",
TextBox3.Text)
Query.Parameters.AddWithValue("@Email", TextBox4.Text)
Query.ExecuteNonQuery()
MessageBox.Show("Record Inserted")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Form1.Show()
End Sub
End Class
Login
Imports System.Data.OleDb
Public Class Form1
While dr.Read
userfound = True
UserID = dr("UserID")
Password = dr("Password")
End While
If userfound = True Then
Me.Hide()
Form3.Show()
Else
MsgBox("SORRY USER_ID AND PASSWORD NOT FOUND")
End If
End Sub
End Sub
End Class
SHOW DETAILS
Imports System.Data.OleDb
Public Class Form3
Dim connString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Users\Hello\Documents\Clg project\Quiz_System.mdb"
Dim MyConn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim tables As DataTableCollection
Dim source1 As New BindingSource
'
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
ds = New DataSet
tables = ds.Tables
da = New OleDbDataAdapter("Select * from [Quiz]", MyConn)
'Change items to your database name
da.Fill(ds, "Quiz") 'Change items to your database name
Dim view As New DataView(tables(0))
source1.DataSource = view
DataGridView1.DataSource = view
End Sub
End Class
9.Develop a windows program of book management system
Imports System.Data.OleDb
Public Class Form1
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Users\Hello\Music\VB.Net\Windows Application\Book
Management\BookManagement.mdb"
Dim MyConn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim tables As DataTableCollection
Dim source1 As New BindingSource
Dim conn_string As String
Dim my_conn As OleDb.OleDbConnection
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
10.Write a console program to implement call by value and
call by reference
Module Module1
Sub Main()
Dim n As Integer = 9
change(n)
Console.WriteLine(n)
Changes(n)
Console.WriteLine(n)
Console.ReadKey()
End Sub
End Module
11.Write a console program to implement constructor and
destructor
Imports System.Console
Module Module1
Class base
Private a As Integer
Private b As Double
Private c As String
Public Sub New(ByVal x As Integer, ByVal y As Double, ByVal
z As String)
WriteLine("CONSTRUCTOR OF BASE CLASS EXECUTED!!!!!")
a = x
b = y
c = z
WriteLine("a=" & a)
WriteLine("b=" & b)
WriteLine("c=" & c)
End Sub
Protected Overrides Sub finalize()
WriteLine("DESTRUCTOR OF BASE CLASS EXECUTED!!!!")
End Sub
End Class
Class derive : Inherits base
Private d As Integer
Public Sub New(ByVal e As Integer, ByVal x As Integer, ByVal
y As Double, ByVal z As String)
MyBase.New(x, y, z)
WriteLine("CONSTRUCTOR OF DERIVED CLASS EXECUTED!!!!")
d = e
WriteLine("d=" & d)
End Sub
End Class
Sub Main()
WriteLine("WHEN WE DECALRE OBJECT OF BASE CLASSS :-")
WriteLine()
WriteLine()
Dim s2 As derive = New derive(40, 50, 176, "")
Console.ReadKey()
End Sub
End Module
12. Write a console program to demonstrate the use of run
time and compile time polymorphism
Module Module1
Class Person
Class CricketPlayer
Inherits Person
Function getNationality()
Return strNationality
End Function
Sub Main()
Console.WriteLine("Polymorphism Example")
Dim Player As New CricketPlayer
Console.WriteLine()
Player.Play()
Dim Person1 As New Person
Console.WriteLine()
Person1.Play()
Dim CricPlayer As New CricketPlayer
Dim person2 As Person
person2 = CricPlayer
Console.WriteLine()
person2.Play()
Console.WriteLine()
Console.ReadKey()
End Sub
End Module
13.write a program to implement abstract method
Module Module1
Public MustInherit Class AbstractClass
Public MustOverride Function Add() As Integer
Public MustOverride Function Mul() As Integer
End Class
End Class
Sub Main()
End Sub
End Module
14.Write a console program to implement interface X
Module Module1
Interface operate
Event Calculate(ByVal x As Integer, ByVal y As Integer)
Function Difference(ByVal a As Integer, ByVal b As Integer)
As Integer
Function Product(ByVal a As Integer, ByVal b As Integer) As
Long
End Interface
Class main_operate
Implements operate
End Class
Sub Main()
Dim x, y, w As Integer
x = 20
y = 80
Dim z As Long
Dim cal As New main_operate
z = cal.Prod(x, y)
w = cal.Dif(x, y)
Console.WriteLine("Substraction value is: " & w & "
Multiplication value is: " & z)
Console.ReadKey()
End Sub
End Module
15.Write a program to implement inheritance
Module Module1
Sub Main()
Dim Obj As New Subclass()
Console.WriteLine("im from subclass {0}", Obj.sum())
Console.WriteLine("im from baseclass {0}", Obj.add())
Console.ReadKey()
End Sub
End Module
Public X As Integer = 10
Public Y As Integer = 25
End Class
Inherits Superclass
Public Z As Integer = 25
Public Function sum() As Integer
Return X + Y + Z
End Function
End Class
16.Write a program to implement access specifiers
Module Module1
Class organisms
Public species As String
Private age As Byte
Protected name As String
End Class
End Class
Sub Main()
Dim obj As New organisms
obj.species = "Ankit"
obj.Setage(7)
Console.Write("{0} is 20 year old", obj.species,
obj.Getage())
Console.ReadKey()
End Sub
End Module
17. Write a program to demonstrate use of My Base and My
Class keyword
Module Module1
Sub Main()
Dim p As parent
Dim c As child
p = New parent
p.p1()
p.p2()
p = New child
p.p1()
Console.ReadLine()
End Sub