You are on page 1of 3

1/17/2020

CODING AND TESTING CODING THE SOLUTION

CODING  Coding involves the process of  After designing the program interface, next
is to add functionality to the form and
translating the algorithm into a
controls through the use of the Code Editor.
specific programming language.
AND TESTING  Testing deals with the process of
 This is done by inserting the VB program
codes into the event procedure of the form or
control.
verifying if the program meet the  An event is a signal that informs an
requirements stated on the problem. application that something important has
occurred. For ex ample, click a control, enter
a tex t.

Examples of controls and their


commonly used events: CODING THE SOLUTION CODING THE SOLUTION
Control Associated Events Action
 The code that performs actions in  To add code, double click on the
Button Click Click mouse button
GotFocus control receives focus
response to events is written in event form or object.
LostFocus control loses focus procedure.
Label DblClick when the component is double-
clicked  Code Editor - Used to write or
Textbox Keypress user presses & releases a key Private Sub btnCompute_Click (…) edit the VB program codes
TextChanged Contents of textbox changes
Form Load Whenever the user loads the form End Sub

1
1/17/2020

CODE EDITOR WINDOW CODING EDITOR WINDOW SAMPLE CODE: PERIMETER


 Declarations Section
Private Sub btnCompute_Click
 Class List  Class list – contains all the
Dim side as Integer
 Method List classes that represent the form
side = Val(txtSide.Text)
and the controls in the project txtSide.Text = 4 * side

 Method list– list all the Private Sub btnExit_Click


associated method for each Application.Exit()
class

Parts of the code ASSIGNMENT STATEMENT CLOSING A PROGRAM


 Assigns a value to a property or variable  Execute the Close Method of the
Note: Dim is a reserved word which
 Operates from right to left Form
means variable declaration
 Methods always have parentheses
 Enclose text strings in quotation marks
As Integer specifies the data type (this will help you distinguish them
(" ") from Properties which nev er have
The function Val is to convert parentheses)
text to numeric value. lblMessage.Text =" Hello World "  Current Form may be referenced as
Me
Me.Close( )

2
1/17/2020

TEST AND DEBUG

 Run Project
– Start Without Full Compile (F5)
– Start With Full Compile (CTRL F5)
 Correct any Errors and Rerun

You might also like