0% found this document useful (0 votes)
20 views25 pages

Gad Pracr From 11

The document outlines a series of practical programming exercises in VB.Net, including the use of various controls such as Toolbars, Panels, and Error Providers. It covers concepts such as class and object creation, inheritance, method overloading and overriding, exception handling, and database connectivity using ADO.Net. Each section includes program code examples and expected outputs for educational purposes.

Uploaded by

inamdarparvej19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views25 pages

Gad Pracr From 11

The document outlines a series of practical programming exercises in VB.Net, including the use of various controls such as Toolbars, Panels, and Error Providers. It covers concepts such as class and object creation, inheritance, method overloading and overriding, exception handling, and database connectivity using ADO.Net. Each section includes program code examples and expected outputs for educational purposes.

Uploaded by

inamdarparvej19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Practical No 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

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


ToolStripButton2.Click
Panel1.BackColor = Color.Green
End Sub
End Class

Output :
 Exercise
1. Write program using picture box control to load an image at run time.

 Output :

2. Write a program to demonstrate the use of Panel Control in VB.Net.

 Output :
Practical No 12

Program Code :
1. Write a program using Tab Control.


Public Class Form1

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


Label1.Text = "Button from FY has been Clicked!"
End Sub

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


Label1.Text = "Button from SY has been Clicked!"
End sub
End Class

Results (output of the program


X. Exercise
1. Write a program to display the traffic signal using timer 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

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


Dim regex As Regex = New Regex("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-
9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")

Dim isValid As Boolean = regex.IsMatch(TextBox1.Text.Trim)

If Not isValid Then


ErrorProvider1.SetError(TextBox1, "Invalid E-mail ID")
Else
MsgBox("Valid Email Id")
End If
End Sub

X. Results (Output of the Program)


2. Write the program code to perform validation using ErrorProvider Control.

 Output :
 Exercise
1. Write a program using ErrorProvider for username and password
authentication.

 Output :

2. Write a program using ErrorProvider for control to validate Mobile Number


and Email ID in GUI appnlication.

 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

Results (output of the program) :


This is Simple
Function Enter
Two Numbers
45
65
Addition is = 110
 Exercise
1. Write a program to identify maximum number using parameterized
function. (Use two Textbox for input a integer number and display output
in Message Box)

 Output :

2. Write a program using recursion(Factorial).

 Output :

Enter Number=

Result

120
Practical No 17

Program Code :

1. Write a program using the concept of class & object in VB.Net.

 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

Results (output of the program)

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:

This is base class


Destructor executing here
Results (output of the program)

a. Constructor Executed
This is base class

b. This is base class


Destructor executing here
Exercise :
1. Implement a program to display any message at run time.(Using Constructor).

 Output :

2. Implement a program to calculate area of circle using parameterized


constructor .

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

Public Class student 'Base Class


Public branch As String = "Computer"
End Class

Public Class details 'Derived Class


Inherits student
Public Function show()
Console.WriteLine("Branch = " & branch)
Return 0
End Function
End Class

XI. Results (output of the program)

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

Public Class addition


Public i, j As Integer
Public Function add(ByVal i As Integer) As Integer
Return i
End Function

Public Function add(ByVal i As Integer, ByVal j As Integer) As Integer


Return i + j
End Function
End Class

Output:

Overloaded Values of Class addition


10
55
Overriding:
Module Module1

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

Public Class parent


Public Overridable Function add(ByVal i As Integer, ByVal j As Integer)
Return (i + j)
End Function
End Class

Public Class child


Inherits parent
Public Overrides Function add(ByVal i As Integer, ByVal j As Integer)
Console.WriteLine("Result of Addition =" & MyBase.add(12, 18)
Return (i + j)
End Function
End Class

Output:
Result of Addition =30
Overloaded Values of Class
addition Result =15

Results (output of the program) :

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.

Public Class Form1

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


Dim num1, num2, div As Integer

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:

A first chance exception of type 'System.OverflowException' occurred in


WindowsApplication8.exe
Division of 5 by zero
 Exercise
1. Write a program for student registration using exception handling.

 Output :
Practical No 24

Program Code
1. Write a program using ADO.Net to the database.

Imports System.Data
Imports System.Data.OleDb

Public Class Form1

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


Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data " &
"Source=C:\Users\Suresh\Documents\Visual Studio 2012 \ Projects \ Datagrid \ stud.mdb")

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 :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy