You are on page 1of 6

Ex.

No: FORM DESIGN


Date:

Aim:
To study about Form Designs in Visual Basic.

Theory:
Forms are needed for creating visually pleasant, consistent and intuitive
interfaces. A form has a certain set of border style for the form, which
includes the following types:
1) None 2) Fixed single 3) Sizeable 4)Fixed Dialog 5) Fixed
tool window 6) Size able tool

The fixed dialog style offers a border and doesn’t allow a form to be resized,
but it lacks minimizing and maximizing buttons. To include these buttons
use fixed single style. Sizeable tool window and fixed tool window styles
are generally used for forms that need to float over and allow changes to be
made to the main forms. The start position of the forms has to be addressed.
1) Manual 2) Windows default 3) center screen 4) centre
owner

When users need to be prevented having control it is easier to disable control


rather than hide it. Disabling the control prevents the user from selecting the
option hence the control can be viewed but not selected.

Steps for form creation:

STEPS:
 Go to the file menu and select new project.

 Then in window that appears select the type of project that has to be
created

29CS247 S.Surya sahithyan


Ex.No: FORM DESIGN
Date:
 On selecting “OK” in step2 the form will be created automatically…
but if another form needs to be created then do step 4

 Go to project and select add form.

Properties of a FORM

AIM:
To create a calculator application in visual
basic that performs the basic arithmetic
operations

ALGORITHM:
1) using label, text, command design the calculator form
2) change the properties of the label, text and command as follows
a. text – name,caption,text
b. command – name, caption
3) write the number code in the number buttons with the event as click
4) write the operation code in the operation buttons with the event as
click
5) write the equal operation code in the equal operation buttons with the
event as click

CODING:

29CS247 S.Surya sahithyan


Ex.No: FORM DESIGN
Date:
Dim first As Integer
Dim op As String

Private Sub div_Click()


If (first = 0) Then
first = Text1.Text
Else
first = first / Val(Text1.Text)
End If
op = "/"
Text1.Text = ""
End Sub

Private Sub mul_Click()


If (first = 0) Then
first = Text1.Text
Else
first = first * Val(Text1.Text)
End If
op = "*"
Text1.Text = ""
End Sub

Private Sub sub_Click()


If (first = 0) Then
first = Text1.Text
Else
first = first - Val(Text1.Text)
End If
op = "-"
Text1.Text = ""
End Sub

Private Sub add_Click()


If (first = 0) Then
first = Text1.Text
Else
first = first + Val(Text1.Text)
End If
op = "+"

29CS247 S.Surya sahithyan


Ex.No: FORM DESIGN
Date:
Text1.Text = ""
End Sub

Private Sub val0_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "0"
End Sub

Private Sub valdot_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "."
End Sub

Private Sub ac_Click()


Text1.Text = ""
first = 0
End Sub

Private Sub val7_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "7"
End Sub

Private Sub equal_Click()


If (op = "+") Then
first = first + Val(Text1.Text)
ElseIf (op = "-") Then
first = first - Val(Text1.Text)
ElseIf (op = "*") Then
first = first * Val(Text1.Text)
ElseIf (op = "/") Then
first = first / Val(Text1.Text)
End If
Text1.Text = first
first = 0
End Sub

Private Sub val8_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "8"

29CS247 S.Surya sahithyan


Ex.No: FORM DESIGN
Date:
End Sub

Private Sub val9_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "9"
End Sub

Private Sub val4_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "4"
End Sub

Private Sub val5_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "5"
End Sub

Private Sub val6_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "6"
End Sub

Private Sub val1_Click()


Text1.Text = ""
ext1.Text = Text1.Text + "1"
End Sub

Private Sub val2_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "2"
End Sub

Private Sub val3_Click()


Text1.Text = ""
Text1.Text = Text1.Text + "3"
End Sub

OUTPUT:

29CS247 S.Surya sahithyan


Ex.No: FORM DESIGN
Date:

29CS247 S.Surya sahithyan

You might also like