Software Development

  Assignment 3 Guide

Implementation Phase


The Program Code Structure

Imagine you have VB open and displaying a coding module.  You could declare all your variables in the module. Then you could use the same variables in both your input and output form.

Module

Declare all Variables

'stored data variables

Public lawnSeedCoverage as Integer

etc.

'input variables

Public rectLawnLength as Single

etc

'output variables

Public bagsLawnSeed as Single

etc

Now imagine you have VB open and displaying the coding window of your input form.  You could structure you code similar to the structure shown below. The first sub routine sets the stored data values, the second sub routine gets the users inputs and the third sub routine carries out the calculations.

Input Form Coding Sheet
Step 1. Input Form - Set the Stored Data Values

Private Sub Form_Load()

        ' you could put code here that executes when the first program starts

        ' set the values of the stored data variables here

        ' ready to use later on

        'example

        lawnSeedCoverage = 30

        lawnSeedinBag = 1000

            etc…..

End Sub

 

Step 2.  Input Form - Get the users input

Private Sub cmdSubmit_Click()

        ' the user clicks the command button

        ' get the values from the input textboxes here

        'example: the two lines below get the values from two textboxes

        rectLawnLength = txtRectLawnLength.Text

        rectLawnWidth = txtRectLawnWidth.Text

            etc…..

       calculate  ‘run the calculate sub routine

End Sub

 

Step 3. Input Form - carry out the calculations

Private Sub calculate()

        'you can put code in that does all the calculations

        'example: the two lines below calculate an area and seed amount

         rectLawnArea = rectLawnLength * rectLawnWidth

         rectLawnSeedAmount = rectLawnArea * lawnSeedCoverage

            etc…..

         Me.Hide    'hide the input form

         Load Form2   'load and show the output form

End Sub

 
   

Now imagine you have VB open and displaying the coding window of your output form.  You could structure you code similar to the structure shown below. The sub routine should contain code for displaying the results of the calculations to the user.

Output Form Coding Sheet

Step 4. Output Form - display the results

If you have labels for displaying your answers then use the code in the Form Load below  If you have textboxes for displaying your answers then use the code in the second Form Load.

Private Sub Form_Load()

        'display the results in labels here

        'example: the two lines below display the amount and

        'number of bags in labels

            lblAmountLseeds.Caption = totalLawnSeedAmount & " grams"

            lblBagsLseeds.Caption = bagsLawnSeed

            etc…..

    End Sub
      

If you have textboxes for displaying your answers then use the code below:-

Private Sub Form_Load()

        'display the results in textboxes here

        'example: the two lines below display the amount and

        'number of bags in textboxes

            txtAmountLseeds.Text = totalLawnSeedAmount & " grams"

            txtBagsLseeds.Text = bagsLawnSeed

            etc…..

    End Sub

   


fini

 

 

   

  Unit Information

Assessment

Syllabus

Scheme of Work

Notes &Tutorials

Assignments

Quizzes

Books & Things

Links