Project File
Project File
Net
BCA-251
Q1: Write down steps and take snapshot to create a Windows Form Application
project in Visual Studio 2010 and write code on the click of a button and then run
the form to show the message Welcome to VB.Net on click of button.
Saurabh Bhandari
00113702014
Saurabh Bhandari
00113702014
Design
Coding
Public Class
Form1
Private Sub
Saurabh Bhandari
00113702014
Output
Q2: WAP to change the back color of textbox, label, command button on the click
command button
of a
Design
4
Saurabh Bhandari
00113702014
Coding
Public Class Form9
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Label1.BackColor = Color.Brown
TextBox1.BackColor = Color.Black
Button1.BackColor = Color.DarkBlue
End Sub
End Class
Output
Saurabh Bhandari
00113702014
Q3: WAP to change the back color and fore color of a form
6
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Me.BackColor = Color.Black
Me.ForeColor = Color.DarkRed
End Sub
End Class
Saurabh Bhandari
00113702014
Output
Q4: Write a program to switch between two forms using show and hide methods
8
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Me.Hide()
Form3.Show()
End Sub
End Class
Output
9
Saurabh Bhandari
00113702014
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim fp As New FontDialog
fp.Font = TextBox1.Font
fp.ShowDialog()
End Sub
End Class
Output
11
Saurabh Bhandari
00113702014
Q6: Design an application to show simple arithmetic operation without using variables.
12
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form4
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
tb3.Text = CInt(tb1.Text) + CInt(tb2.Text)
tb4.Text = CInt(tb1.Text) * CInt(tb2.Text)
If tb1.Text > tb2.Text Then
tb5.Text = CInt(tb1.Text) - CInt(tb2.Text)
Else
tb5.Text = CInt(tb2.Text) - CInt(tb1.Text)
End If
If tb1.Text > tb2.Text Then
tb6.Text = CInt(tb1.Text) Mod CInt(tb2.Text)
Else
tb6.Text = CInt(tb2.Text) Mod CInt(tb1.Text)
13
Saurabh Bhandari
00113702014
End If
End Sub
End Class
Output
Q7: Design a form to find to area of circle whose radius is given by the user and result
shown in both label and message box
14
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form4
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Label2.Text = 22 / 7 * (CInt(TextBox1.Text) * CInt(TextBox1.Text))
'MessageBox.Show(Label2.Text)
End Sub
End Class
Output
15
Saurabh Bhandari
00113702014
Q8: Design a form to find the area and perimeter of rectangle and square
16
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form5
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
tb4.Text = (2 * (CInt(tb1.Text) + CInt(tb2.Text)))
tb5.Text = (4 * (CInt(tb3.Text)))
tb6.Text = CInt(tb1.Text) * CInt(tb2.Text)
tb7.Text = CInt(tb3.Text) * CInt(tb3.Text)
tb4.Enabled = False
tb5.Enabled = False
tb6.Enabled = False
tb7.Enabled = False
End Sub
End Class
Output
17
Saurabh Bhandari
00113702014
Q9: Design a form to find out the average and percentage of 4 numbers
18
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Label5.Text = (CInt(TextBox1.Text) + CInt(TextBox2.Text) + CInt(TextBox3.Text) +
CInt(TextBox4.Text)) / 4
Label6.Text = Label5.Text + "%"
End Sub
End Class
Output
19
Saurabh Bhandari
00113702014
20
Saurabh Bhandari
00113702014
Q10: Write a program to find the area of circle whose radius is given by the user at run
time.
Design
Coding
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim Radius As Integer = InputBox("Enter the Radius", "Enter Radius")
Dim Area As Double = (22 / 7) * (CInt(Radius) * CInt(Radius))
MessageBox.Show(Area, "Area")
End Sub
End Class
Output
21
Saurabh Bhandari
00113702014
Q11: Create an application to check range the various data types using maximum and
minimum properties. Also show the use of get type method
22
Saurabh Bhandari
00113702014
Design
Coding
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim a As Double
TextBox1.Text = Byte.MinValue
TextBox2.Text = Byte.MaxValue
TextBox3.Text = CByte(TextBox2.Text).GetType.ToString()
TextBox4.Text = Short.MinValue
TextBox5.Text = Short.MaxValue
TextBox6.Text = CShort(TextBox5.Text).GetType.ToString()
TextBox7.Text = Integer.MinValue
TextBox8.Text = Integer.MaxValue
TextBox9.Text = CInt(TextBox8.Text).GetType.ToString()
TextBox10.Text = Long.MinValue
TextBox11.Text = Long.MaxValue
23
Saurabh Bhandari
00113702014
TextBox12.Text = CLng(TextBox11.Text).GetType.ToString()
TextBox13.Text = Decimal.MinValue
TextBox14.Text = Decimal.MaxValue
TextBox15.Text = CDec(TextBox14.Text).GetType.ToString()
TextBox16.Text = Single.MinValue
TextBox17.Text = Single.MaxValue
TextBox18.Text = CSng(TextBox17.Text).GetType.ToString()
TextBox19.Text = Double.MinValue
TextBox20.Text = Double.MaxValue
TextBox21.Text = a.GetType.ToString()
End Sub
End Class
Output
Q13: Design a simple Student login form in VB.Net using the properties of textbox, label
and command button controls.
Design
24
Saurabh Bhandari
00113702014
Coding
Button 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim fp As New Form6
If tb1.Text = ("Student") And tb2.Text = ("IITM") Then
MessageBox.Show("You Have Successfully Logged in","Log-in
Status",MessageBoxButtons.OK,MessageBoxIcon.Asterisk)
Else
MessageBox.Show("Invalid Username or Password
:P", "Error Message",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Button 2
25
Saurabh Bhandari
00113702014
Output
26
Saurabh Bhandari
00113702014
Coding
Button 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
If TextBox1.Text = "" And TextBox2.Text = "" And TextBox3.Text = "" And TextBox4.Text = ""
And TextBox5.Text = "" And TextBox6.Text = "" Then
MessageBox.Show("Please Fil all the Information", "Error Message", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
Else
27
Saurabh Bhandari
00113702014
Output
28
Saurabh Bhandari
00113702014
Q14: Write a program to show the use of Option Explicit ON\OFF statement.
29
Saurabh Bhandari
00113702014
Design
Coding
Option Explicit Off
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
a = TextBox1.Text()
b = TextBox2.Text()
TextBox3.Text = CInt(a) + CInt(b)
End Sub
End Class
Output
30
Saurabh Bhandari
00113702014
Coding
Option Explicit On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
a = TextBox1.Text()
b = TextBox2.Text()
TextBox3.Text = CInt(a) + CInt(b)
End Sub
End Class
Output
31
Saurabh Bhandari
00113702014
32
Saurabh Bhandari
00113702014