GUI Word File
GUI Word File
A LOBORATORY MANUAL
FOR
GUI APPLICATION
DEVELOPMENT USING VB.NET
(22034)
GUI PROGRAM OUTPUTS
***
1|Page
PRACTICAL NO. 2 : Design VB.NET application using Existing Namespace and User
Defined.
Q.1] Write a program using user defined and existing namespaces in VB.NET
2|Page
Q.2] Write a program to implement the namespace student in your VB.NET Application.
.
PROGRAM
OUTPUT
3|Page
PRACTICAL NO. 3 : Implement a Message Box program & Arithmatic Expressions.
PROGRAM
Module Module1
Dim i, j, r As Integer
Sub Main()
Console.WriteLine("Enter First Value=")
i = Console.ReadLine()
Console.WriteLine("Enter Second Value=")
j = Console.ReadLine()
Console.ReadLine()
MsgBox("Addition =" & (i + j))
MsgBox("Substraction =" & (i - j))
MsgBox("Multiplication =" & (i * j))
MsgBox("Division =" & (i / j))
End Sub
End Module
OUTPUT
4|Page
Q.2] Implement the program to generate result of any arithmetic operation using MessageBox().
PROGRAM
OUTPUT
5|Page
PRACTICAL NO. 4:Implement a program for If-else control structure in VB.Net.
PROGRAM
Module Module1
Sub Main()
Dim n As Integer
Console.WriteLine("Enter a Number")
n = Console.ReadLine()
If (n > 0) Then
Console.WriteLine("Number is Positive")
Else
Console.WriteLine("Number is Negative")
End If
Console.ReadLine()
End Sub
End Module
OUTPUT
6|Page
PRACTICAL NO. 5: Implement a program for select case control structure in VB.NET.
PROGRAM
Module Module1
Sub Main()
Dim grade As String
Console.WriteLine("Enter Your grade")
grade = Console.ReadLine()
Select Case grade
Case "A"
Console.WriteLine("High Distinction")
Case "A-"
Console.WriteLine("Distinction")
Case "B"
Console.WriteLine("Credit")
Case "C"
Console.WriteLine("Pass")
Case Else
Console.WriteLine("Fail")
End Select
Console.ReadLine()
End Sub
End Module
OUTPUT
7|Page
Q.2]Develop a program for performing arithmetic operation.
PROGRAM
Module Module1
Sub Main()
Dim grade As String
Console.WriteLine("Enter Your grade")
grade = Console.ReadLine()
Select Case grade
Case "A"
Console.WriteLine("High Distinction")
Case "A-"
Console.WriteLine("Distinction")
Case "B"
Console.WriteLine("Credit")
Case "C"
Console.WriteLine("Pass")
Case Else
Console.WriteLine("Fail")
End Select
Console.ReadLine()
End Sub
End Module
OUTPUT
8|Page
PRACTICAL NO.6:Implement a program for While , Do loops in VB.NET.
Q.1]Write a program using While statement to print the prime number between 1 to 100.
PROGRAM
Module Module1
Sub Main()
Dim i, j, c As Integer
c=0
i=2
While (i <= 100)
j=2
While (j < i)
If (i Mod j = 0) Then
Exit While
ElseIf (i = j + 1) Then
Console.WriteLine(i)
End If
j=j+1
End While
i=i+1
End While
Console.ReadLine()
End Sub
End Module
OUTPUT
9|Page
PRACTICAL NO.7:Implement a program to demonstrate the use of For , For-each Loops in
VB.NET.
PROGRAM
Module Module1
Sub Main()
Dim Array() As Integer = {12, 34, 56, 37, 78, 53, 98, 22, 19, 68}
Dim Key As Integer
Dim IsKeyFoundFlag As Boolean = False
98, 22, 19, 68}
Console.WriteLine("Enter element to search: ")
Key = Console.ReadLine()
For i As Integer = 1 To Array.Length() - 1
If Array(i) = Key Then
IsKeyFoundFlag = True
End If
Next
If IsKeyFoundFlag = True Then
Console.WriteLine("Element present.")
Else
Console.WriteLine("Element absent.")
End If
Console.ReadKey()
End Sub
End Module
OUTPUT
10 | P a g e
Q.2]Write program using for next loop statement to find the Armstrong number between 1 to
500.
PROGRAM
Module Module1
Sub Main()
Dim i As Integer
Console.Write("Armstrong Numbers between 1 to 500: ")
For i = 1 To 500 Step 1
Dim sum, num, digit As Integer
sum = 0
num = i
While (num > 0)
digit = num Mod 10
sum += (digit * digit * digit)
num = num \ 10
End While
If (sum = i) Then
Console.WriteLine(i)
End If
Next
Console.ReadLine()
End Sub
End Module
OUTPUT
11 | P a g e
PRACTICAL NO.8:Design windows application using Text Box , Label & Button.
PROGRAM
Public Class Form1
Private Function Factorial(ByVal num As Integer) As Long
Dim fact As Long = 1
Dim i As Integer
For i = 1 To num
fact *= i
Next
Factorial = fact
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fact As Long
fact = Factorial(TextBox1.Text)
MessageBox.Show("Factorial of " & TextBox1.Text &
" is " & fact, "Factorial", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
End Class
OUTPUT
12 | P a g e
Q.2]Write a program to change the background color of the form when click on different
button.
PROGRAM
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.BackColor = Color.Red
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.BackColor = Color.Green
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.BackColor = Color.Yellow
End Sub
End Class
OUTPUT
13 | P a g e
PRACTICAL NO.9:Design windows application using Radio button & Check box.
PROGRAM
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
If (RadioButton1.Checked = True) Then
MessageBox.Show("You are Select VB.NET")
End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
If (RadioButton2.Checked = True) Then
MessageBox.Show("You are Select JAVA")
End If
End Sub
End Class
OUTPUT
14 | P a g e
Q.2]Write a program using radiobutton to change the bulb stste ON/OFF.
PROGRAM
Public Class Form1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
PictureBox2.Show()
PictureBox1.Hide()
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
PictureBox1.Show()
PictureBox2.Hide()
End Sub
End Class
OUTPUT
15 | P a g e
Q.3]Write a program to change the forecolour of text in label using different Radiobutton such
as Red ,Green ,Blue.
PROGRAM
OUTPUT
16 | P a g e
PRACTICAL NO.10:Design window application using listbox & combo box.
PROGRAM
Public Class Student_Registration
Private Sub Student_Registration_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
ComboBox1.Items.Add("First Semester")
ComboBox1.Items.Add("Second Semester")
ComboBox1.Items.Add("Third Semester")
ComboBox1.Items.Add("Fourth Semester")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles ComboBox1.SelectedIndexChanged
If (ComboBox1.SelectedIndex = 0) Then
ListBox1.Items.Clear()
ListBox1.Items.Add("Chemistry")
ListBox1.Items.Add("Physics")
ListBox1.Items.Add("Maths")
ListBox1.Items.Add("English")
End If
If (ComboBox1.SelectedIndex = 1) Then
ListBox1.Items.Clear()
ListBox1.Items.Add("PIC")
ListBox1.Items.Add("Maths")
ListBox1.Items.Add("CHM")
ListBox1.Items.Add("WPD")
End If
If (ComboBox1.SelectedIndex = 2) Then
ListBox1.Items.Clear()
ListBox1.Items.Add("DBM")
ListBox1.Items.Add("OOP")
ListBox1.Items.Add("CGR")
ListBox1.Items.Add("DSU")
End If
If (ComboBox1.SelectedIndex = 3) Then
ListBox1.Items.Clear()
ListBox1.Items.Add("JPR")
ListBox1.Items.Add("DCC")
ListBox1.Items.Add("GUI")
ListBox1.Items.Add("SEN")
End If
End Sub
End Class
OUTPUT
17 | P a g e
Q.2]Write a program to demonstrate the use of listbox and comboBox.
PROGRAM
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
End Class
OUTPUT
18 | P a g e
PRACTICAL NO.11:Design windows application using picture box & panel.
PROGRAM
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dynamicPanel As New Panel()
dynamicPanel.Name = "Panel1"
dynamicPanel.Size = New System.Drawing.Size(228, 200)
dynamicPanel.BackColor = Color.Pink
Dim textBox1 As New TextBox()
textBox1.Location = New Point(10, 10)
textBox1.Text = "Enter Your Name"
Dim checkBox1 As New CheckBox()
checkBox1.Location = New Point(10, 50)
checkBox1.Text = "Male"
checkBox1.Size = New Size(200, 30)
Dim checkBox2 As New CheckBox()
checkBox2.Location = New Point(10, 90)
checkBox2.Text = "Male"
checkBox2.Size = New Size(200, 30)
dynamicPanel.Controls.Add(textBox1)
dynamicPanel.Controls.Add(checkBox1)
dynamicPanel.Controls.Add(checkBox2)
Controls.Add(dynamicPanel)
End Sub
End Class
OUTPUT
19 | P a g e
Q.2]Write a program using toolbox,form and panel controls.
PROGRAM
OUTPUT
20 | P a g e
PRACTICAL NO.12:Design window application using tab control & timer.
PROGRAM
OUTPUT
21 | P a g e
Q.2]Write a program using tab control.
PROGRAM
OUTPUT
22 | P a g e
PRACTICAL NO.13 AND 14:Implement a windows application to perform validation on
various control.
PROGRAM
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 E-Mail ID")
End If
End Sub
OUTPUT
23 | P a g e
Q.2]Write a program using error provider for username and password authentication.
PROGRAM
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
ErrorProvider1.SetError(TextBox1, "Please Enter Your Name")
Else
ErrorProvider1.SetError(TextBox1, "")
End If
If TextBox2.Text = "" Then
ErrorProvider1.SetError(TextBox2, "Please Enter Your Password")
Else
ErrorProvider1.SetError(TextBox2, "")
End If
End Sub
End Class
OUTPUT
24 | P a g e
PRACTICAL NO.16:Write a program to demonstrate use of simple function and parameterized
function.
PROGRAM
OUTPUT
25 | P a g e
PRACTICAL NO.17:Understand the concept of class and object of class.
Q.1]Write a program to identify the volume of box class ,with three data member ,length ,
breadth and height.
PROGRAM
Module Module1
Sub Main()
Dim obj As Box = New Box()
Dim vol As Integer
vol = obj.volume(2, 4, 4)
Console.WriteLine("Length =" & obj.l)
Console.WriteLine("Breadth =" & obj.b)
Console.WriteLine("Height =" & obj.h)
Console.WriteLine("Volume =" & vol)
Console.ReadLine()
End Sub
Class Box
Public l, b, h As Integer
Function volume(ByVal i As Integer, ByVal j As Integer,
_ByVal k As Integer)
Dim v As Integer
l=i
b=j
h=k
v=l*b*h
Return v
End Function
End Class
End Module
OUTPUT
26 | P a g e
Q.2]Implement a program to accept values from combo box and display average of this in
message box using class.
PROGRAM
OUTPUT
27 | P a g e
PRACTICAL NO.18:Implement a program for class constructor and destructor to De-Allocate
Memory.
PROGRAM
-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
�
-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
28 | P a g e
Q.2]Implement a program to display any message at run time.(using constructor)
PROGRAM
Module Module1
Sub Main()
Dim obj As New sample
obj.display()
Console.ReadLine()
End Sub
Class sample
Public Sub New()
Console.WriteLine("This is Constructor")
End Sub
Sub display()
Console.WriteLine("This is Method")
End Sub
End Class
End Module
OUTPUT
PROGRAM
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
OUTPUT
30 | P a g e
Q.2] Implement a program for inheritance where students is child class and faculty is base class.
PROGRAM
Module Module1
Sub Main()
Dim s As New student
s.branch()
s.year()
Console.ReadLine()
End Sub
Class faculty
Dim b As String = "Computer"
Sub branch()
Console.WriteLine("Branch = " & b)
End Sub
End Class
Class student
Inherits faculty
Dim y As String = "Second Year"
Sub year()
Console.WriteLine("Year = " & y)
End Sub
End Class
End Module
OUTPUT
PROGRAM
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
PROGRAM
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
Module Module1
Sub Main()
Dim obj As New EmpInfo
obj.ShowInfo()
Console.ReadLine()
End Sub
End Module
Public Class EmpPersonalDetails
Dim name As String
Dim address As String
Public Overridable Function ShowInfo()
Console.WriteLine("Employee Name" & name)
Console.WriteLine("Employee Address" & address)
End Function
End Class
Public Class EmpInfo
Inherits EmpPersonalDetails
Dim EmpId As Integer
Dim sallary As Integer
Dim JoinDate As Date
Overloads Function ShowInfo()
MyBase.ShowInfo()
Console.WriteLine("Employee ID" & EmpId)
Console.WriteLine("Employee Sallary" & sallary)
Console.WriteLine("Employee Joining Date" & JoinDate)
End Function
End Class
OUTPUT
Q.2]Implement a window application for show string concatenation using overload method.
33 | P a g e
PROGRAM
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str1, str2, str3 As String
str1 = TextBox1.Text
str2 = TextBox2.Text
str3 = str1 + str2
TextBox3.Text = str3
End Sub
End Class
OUTPUT
34 | P a g e