You are on page 1of 3

FP613 : .

NET TECHNOLOGY

Writing Visual Basic Projects – Three step process:

Planning:
1. Design the user interface – draw a sketch on the screens the user will see when running the
project. On the sketch, show the forms and all controls that you plan to use. Indicate the
names that you plan to give the form and each of objects on the form. Before proceed with
any more steps, consult with the user and make sure both of you agree on the look and feel
of the project.
2. Plan the properties – For each object, write down the properties that you plan to set or
change during the design of the form. Use OPS (Object-Property-Setting)
3. Plan the basic code (pseudo code) – Plan the procedure that will execute when the project
runs. Determine which event require action to be taken and make a step by step plan for
those actions. Use TOE (Task-Object-Event) or Table Procedure-Action/Pseudo code

Programming:
1. Define the user interface – create the forms and controls that you designed in the planning
stage
2. Set the properties – give each object name and define such attributes as the contents of a
label, size of text, and the word that appear on the top of button and in the form’s title bar.
3. Write the basic code – Use basic programming statements (called Basic Code) to carry out
the actions needed by our program.

Visual Basic Code Statements

1. The remarks Statement-comment


‘This is my project

2. The Assignment Statement – from right to left


Eg: lblMessage.Text=”Hello World”  lblMessage.Text is replaced by Hello World

General Form : Object.Property = value

Eg: lblAddress.Text=”SgLang , PSIS”


intNumber = 12
lblMessage.BackColor=Color.Red

General Form : Object.Method()

Eg: btnHello.Hide()
frmMessage.Show()
Me.Close()
txtName.Focus()

1
3. Coding for the controls

a. Clearing the textboxes and labels


Setting the property to an empty string (null string /zero-length string) or use Clear
method.

Eg: txtName.Text=”” ‘Clear the content


lblMessage.Text=”” ‘Clear the content
txtDataEntry.Clear() ‘Clear the content

b. Resetting the focus


Insertion point to appear at the object where the user is expected to type.

Eg: txtName.Focus() ‘Make the insertion point appear here

c. Setting the checked property of radio buttons and check boxes


Radio buttons and check boxes is to allow the user to make selection. Can selset or
deselect radio buttons and checkboxes at design time (to set initial status) or at run time
(to respond to an event).

Eg: radRed.Checked = True ‘make button selected


chkDisplay.Checked=True ‘make box selected
chkDisplay.Checked=False ‘make box unselected

d. Setting Visibility at Run Time


Eg: lblMessage.Visible=False
lblMessage.Visible=chkDisplay.Checked
‘Visibility match the checkbox.
‘When the checkbox is checked (Checked=True) the label is visible.

e. Changing the color of text – The color constant


Eg: Color.Blue
txtName.ForeColor=Color.Red

f. Changing Multiple Properties of a control


Eg: txtTitle.Visible=True
txtTitle.ForeColor=Color.White
txtTitle.Focus()

With txtTitle
General Form:
.Visible=True
With ObjectName . ForeColor=Color.White
Statement .Focus()
End With End With

g. Concatenating Text (&)


Eg: lblMessage.text = “Your name is: “ & txtName.Text
txtNameAnd Address.Text=txtName.text & txtAddress.Text

h. Continuing Long Program Lines (line-continuation character)


Eg: lblGreeting.Text=”Greeting” & txtName.text & “: “ _
“You have been selected to win a free prize.” & _
“ just send us RM100 for postage and handling.”

2
Example: Label:
lblMessage

Button:
Button: btnSpanish
btnEnglish

Button:
btnExit

Class definition – a block of code that specifies/defines


the attributes and behaviours of an object. Eg: frmHello
class definition specifies the attriburte and behaviours of
a frmHello object

Indicates that the Parameter and


procedure represent information
handles/associated that is passed to the
with the btnExit object procedure when it is
is clicked invoked

You might also like