Gad Pracr From 11
Gad Pracr From 11
Program Code :
1. Write a program using Toolbar, Form and Panel Controls.
Public Class Form1
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles
ToolStripButton1.Click
Panel1.BackColor = Color.Red
End Sub
Output :
Exercise
1. Write program using picture box control to load an image at run time.
Output :
Output :
Practical No 12
Program Code :
1. Write a program using Tab Control.
Output :
Practical No 13 & 14
Program Code :
1. Write a program using Error Provider and Regular Expression.
Imports System.Text.RegularExpressions
Public Class Form1
Output :
Exercise
1. Write a program using ErrorProvider for username and password
authentication.
Output :
Output :
Practical No 16
Program Code :
1. Write a program using Simple Function and Parameterized Function.
Module Module1
Sub Main()
show()
Dim a, b As Integer
Console.WriteLine("Enter Two Numbers")
a = Console.ReadLine()
b = Console.ReadLine()
Add(a, b)
Console.WriteLine("Addition is = " & Add(a, b))
Console.ReadLine()
End Sub
Public Function show()
Console.WriteLine("This is Simple Function")
End Function
Public Function Add(ByVal i As Integer, ByVal j As Integer)
Dim sum As Integer
sum = i + j
Return sum
End Function
End Module
Output :
Output :
Enter Number=
Result
120
Practical No 17
Program Code :
Module Module1
Sub Main()
Dim obj As New Test 'Creating a object obj for Test Class
obj.disp() 'Calling the disp method using obj
Console.ReadLine()
End Sub
End Module
Public Class Test
Sub disp()
Console.WriteLine("Welcome to VB.NET")
End Sub
End Class
Welcome to VB.NET
X. Exercise
1. Write a program to identify Volume of Box Class, with three data
members, length, breadth and height.
Output :
2. Implement a program to accept values from Combo Box and Display average of
this in message box using class.
Output :
Practical No 18
Program Code
1. Write a program to demonstrate the use of constructor & destructor.
A) Constructor –
Module Module1
Sub Main()
Dim obj As New syco
obj.show()
Console.ReadLine()
End Sub
Public Class syco
Public Function show()
Console.WriteLine("This is base class")
End Function
Sub New()
Console.WriteLine("Constructor Executed") End Sub
End Class
End Module
OUTPUT:
Constructor Executed
This is base class
Module Module1
Sub Main()
Dim obj As New syco
obj.show()
End Sub
End Module
Public Class syco
Public Function show()
Console.WriteLine("This is base Class")
End Function
Protected Overrides Sub Finalize()
Console.WriteLine("Destructor executing here")
Console.ReadLine()
End Sub
End Class
OUTPUT:
a. Constructor Executed
This is base class
Output :
OUTPUT:
Area of Circle = 12.56
Practical No 19
Program Code
1. Write a program using concept of Inheritance.
Module Module1
Sub Main()
Dim obj As New details
obj.show()
Console.ReadLine()
End Sub
End Module
Branch = Computer
Exercise
1. Implement a program for inheritance where Student is Child Class and
faculty is Base class.(Take Appropriate variable in Base and Child class)
Output :
Practical No 20 & 21
Program Code
1. Write a program to implement the concept of method overloading &
overriding.
Overloading:
Module Module1
Sub Main()
Dim res As New addition
Console.WriteLine("Overloaded Values of Class addition")
Console.WriteLine(res.add(10))
Console.WriteLine(res.add(35, 20))
Console.ReadLine()
End Sub
End Module
Output:
Sub Main()
Dim obj As New child
Dim result As Integer
result = obj.add(10, 5)
Console.WriteLine("Overloaded Values of Class addition")
Console.WriteLine("Result =" & result) Console.ReadLine()
End Sub
End Module
Output:
Result of Addition =30
Overloaded Values of Class
addition Result =15
In the above overloading example the same function add is called to perform
different operations based on different arguments.
In the above overriding the parent class function add is overridden in the child
class using the MyBase.add(12, 18) statement. So first the overridden value is displayed,
then the value from child class is display.
Exercise :
1. Implement a windows application for show string concatenation using
overload method
Output :
Practical No 23
Program Code
1. Write any program using Exception handling.
num1 =Val(TextBox1.Text)
num2 = Val(TextBox2.Text)
Try
div = num1 / num2
MsgBox("Division is" & div)
Catch ex As OverflowException
Console.WriteLine("Division of {0} by zero", num1)
End Try
End Sub
End Class
Output:
Output :
Practical No 24
Program Code
1. Write a program using ADO.Net to the database.
Imports System.Data
Imports System.Data.OleDb
Conn.Open()
Dim cmd As New OleDbCommand("Select * From Marks", conn)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "Marks")
DataGrid1.CaptionText = "marks"
DataGrid1.DataSource = ds
DataGrid1.DataMember = "marks"
End Sub
End Class
Output :
Exercise
1. Design the windows application that will display the content of a table in
MS-Access database on DataGrid control using data adapter.
Output :