Download presentation
Presentation is loading. Please wait.
Published byKristian Hubbard Modified over 9 years ago
1
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions
2
Core VB steps 1.Design an interface (create paper prototype) 2.Turn this design into a VB form 3.Code events to occur 4.Test and debug
3
Screen Design
6
Step 1: Create a Paper Prototype Get a piece of paper and pencil Sketch the user interface display boundaries Sketch on the input areas Sketch on the output areas Sketch on the interactive elements (e.g. buttons) Sketch on any information areas Scribble notes onto design to explain each part of the sketch
7
Have a go… Design a single form application interface that allows a user to convert currencies –Take a piece of paper… that’s the interface form –Sketch the overall shape of the interface form input, output, interactive (button) areas any information areas –Scribble some notes to say what controls do…
9
Core VB steps 1.Design an interface (sketch paper prototype) 2.Turn this design into a VB form 3.Code events 4.Test and debug 1.Design an interface (sketch paper prototype) 2.Turn this design into a VB form 3.Code events 4.Test and debug
10
Step 2: Turning design into a form Place controls onto a VB form –Input areas (e.g. textboxes, check box, radio button, list box) –Output areas (e.g. labels, pictures, lines,) –Information areas (e.g. labels, progressive bar) –Interactive elements (e.g. command buttons, menu items) Arrange the layout & size of controls –Information should flow vertically or horizontally –Top → Bottom, Left → Right (similar to reading a book) –Most important information at top left Edit the properties of a control –E.g. name and text contents –Access Keys –Tab Index Properties
11
Step 2: Turning design into a form
12
Qualities of a Good Programmer Correct scope is used Accurate & consistent naming Code is documented well Code is broken into modules Code is in logical sequence Correct selection structures are used
13
Structured Programming This is about building blocks of code
14
Structured Programming Simple Sequence Lines of codes to undertake tasks
15
Structured Programming Control Structure e.g. selection Lines of codes to undertake tasks If condition Then Lines of codes to undertake tasks Else Lines of codes to undertake tasks EndIf Lines of codes to undertake tasks
16
Structured Programming Control Structure e.g. repetition Lines of codes to undertake tasks Do While condition Lines of codes to undertake tasks Loop Lines of codes to undertake tasks
17
Structured Programming Form Event Procedures Click on Clear Button Lines of codes to undertake tasks Enter Text into Text Box Lines of codes to undertake tasks Click on Calculate Button Lines of codes to undertake tasks Do While condition Lines of codes to undertake tasks Loop Lines of codes to undertake tasks Click on Exit Button Lines of codes to undertake tasks
18
Structured Programming Form Level Entry Form Enter Text into Text Box Lines of codes to undertake tasks Click on Exit Button Lines of codes to undertake tasks Calculate Form Click on Clear Button Lines of codes to undertake tasks Enter Text into Text Box Lines of codes to undertake tasks Click on Exit Button Lines of codes to undertake tasks Display Form Click on Clear Button Lines of codes to undertake tasks Click on Exit Button Lines of codes to undertake tasks
19
Structured Programming Event Procedure/User Procedure Click on ThrowIt Button Lines of codes to undertake tasks Enter Text into Entry Box Lines of codes to undertake tasks Click on Result Button Lines of codes to undertake tasks User Defined Procedure Lines of codes to undertake tasks
20
User Defined Procedures Two purposes 1.To execute a block of code (User Defined) Sub Procedure 2.To execute code and return a result Function Procedure
21
these are given a name look very similar to an event Procedure activated using the Call command line of code Call CalcTimeOfDay line of code Private Sub CalcTimeOfDay() lines of code End Sub 1. User Defined Sub Procedure
22
2. Function Procedure these are given a name look very similar to an event Procedure usually activated with the "=" assignment character line of code IntTotalSpeed = CalculateSpeed () line of code Private Function CalculateSpeed() As Integer lines of code Return SomeValue End Function
23
Passing Variables
24
There are two ways we can pass data in the form of variables, in and out of sub routines/functions 1.Passing By Value ByVal –Sub routine gets a copy of the variable –Variable’s original value is not altered 2.Passing By reference ByRef –Sub routine is told variable location (reference) –Variable’s original value is altered
25
Passing Variables Private Sub YoyoPause (By Ref strYoTime As String) lines of code End Sub Private Function SpeedCalculate(ByVal intSpeedTot as Integer) As Integer lines of code Return SomeValue End Function
26
THE END of the lecture
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.