You are on page 1of 14

VISUAL PROGRAMING

SUBMITTED BY:-
NAME: KANCHAN NEHRA
ROLL NO: 12003069
GROUP: 3ME3
SEMESTER: 5TH
YEAR: THIRD

SUBMITTED TO:-
DR. NAVJOT KAUR
INDEX

1. Write a Program to change Forecolor of the


text in textbox.
2. Find area of a circle using textbox, Label and
Button
3. Write a program to add two Numbers.
4. Write a Program to find greatest of three
numbers
5. : Write a program to calculator using Module
level Declaration.
6. Write a program to show difference between
Dim and Static Variables.
7. Write a program to use different Datatypes.
8. Write a program to show linking of Forms
using public variables.
EXPERIMENT: 1
Aim: Write a Program to change Forecolor of the text in textbox.

SYNTAX:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
TextBox1.ForeColor = Color.Red
End Sub

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


Button2.Click
TextBox1.ForeColor = Color.Green
End Sub
End Class

Output :
EXPERIMENT: 2
Aim : Find area of a circle using textbox, Label and Button.

SYNTAX:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim r, area As Double
r = TextBox1.Text
area = 3.14 * r * r
TextBox2.Text = area

End Sub
End Class
OUTPUT:
EXPERIMENT: 3
Aim: Write a program to add two Numbers.

SYNTAX:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim x, y, sum As Double
x = TextBox1.Text
y = TextBox2.Text
sum = x + y
TextBox3.Text = sum
End Sub
End Class

OUTPUT:
EXPERIMENT: 4
Aim : Write a Program to find greatest of three numbers.

SYNTAX:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim x, y, z As Double
x = TextBox1.Text
y = TextBox2.Text
z = TextBox3.Text
If (x > y) And (x > z) Then
MsgBox("Greatest number is :-" & x)
ElseIf (y > x) And (y > z) Then
MsgBox("Greatest number is :-" & y)
Else
MsgBox("Greatest number is :-" & z)

End If

End Sub
End Class
OUTPUT:
EXPERIMENT: 5
Aim: Write a program to calculator using Module level Declaration.

SYNTAX:
Public Class Form1
Private x, y, z As Double

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


Button2.Click
x = TextBox1.Text
y = TextBox2.Text
z = x - y
TextBox3.Text = z
End Sub

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


Button3.Click
x = TextBox1.Text
y = TextBox2.Text
z = x * y
TextBox3.Text = z
End Sub

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


Button4.Click
x = TextBox1.Text
y = TextBox2.Text
If (y = 0) Then
MsgBox("value of y cannot be 0")
Else
z = x / y
TextBox3.Text = z
End If
End Sub

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

End Sub

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


Button5.Click
MsgBox("come Again")
End Sub

Private Sub sum_Click(sender As Object, e As EventArgs) Handles button1.Click


x = TextBox1.Text
y = TextBox2.Text
z = x + y
TextBox3.Text = z
End Sub

Private Sub Label1_Click(sender As Object, e As EventArgs) Handles label1.Click

End Sub
End Class

OUTPUT:
a9 Form1 — X

enter the value of x 23

enter the value of y 34

result —11

sum sub multiply divide

enter the value of x 23

enter the value of y 0

Microsoft.VisuaIBasic.Core X
result 2300

value of y cannot be 0
sum sub

OK
EXPERIMENT: 6
Aim: Write a program to show difference between Dim and Static
Variables.

SYNTAX:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim x As Integer
x = X + 1
TextBox1.Text = x
End Sub

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


Button2.Click
Static x As Integer
x = X + 1
TextBox2.Text = x
End Sub
End Class

OUTPUT:
EXPERIMENT: 7
Aim: Write a program to use different Datatypes.

SYNTAX:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a As String
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
MsgBox("my name is " & a & " and roll no is " & b)
End Sub
End Class
OUTPUT:
EXPERIMENT: 8
Aim: Write a program to show linking of Forms using public variables.

SYNTAX:
Form 1:-
Public Class Form2
Public Property stringpass As String
Private Sub Form1_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
Label1.Text = stringpass

End Sub
End Class

Form 2:-
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim obj As New Form2
obj.stringpass = TextBox1.Text
obj.Show()
Me.Hide()

End Sub
End Class
OUTPUT:

You might also like