Home
Search this site:

    Good Code

    Before you finish this unit, it is important for you to understand that when writing code it should be readable and easily understandable by other people and by yourself after a long period of time. Following are some guidelines for writing good code:

    • Use meaningful names for your variables

    • Always declare variables in a Dim statement

    • Use indentation of logical blocks of code to make start and end of loops etc clearer

    • Use empty lines between blocks of code that are logically different eg between blocks of code doing one task and the next block doing something different

    • Use comments in your code explaining what each part is doing

    • At the beginning of your code write comments with the names of all programmers and the date of creation and any major updates

    • VB Index

    • Starting a new Project

    • Parts of the VB window

    • Saving Projects

    • Printing out your projects

    • Making Standalone Programs

    • Events and Procedures

    • Controls, Properties, Events, Procedures defined

    • Adding Controls (Objects) to the interface

    • Naming Controls - Conventions

    • Properties - setting

    • Setting Form Width

    • Adding Buttons and setting their properties

    • Text Boxes

    • Pictures 

    • Lines and Shapes

    • Labels - Autosize, Wordwrap

    • Radio Buttons

    • Scroll Bars

    • Message Boxes

    • Input Boxes

    • Boolean Logic

    • VB Colours and RGB values

    • Errors and Bugs

    • Comment Lines

     

    • Variables

      • What are Variables 

      • Rules for Naming Variables

      • Declaring Variables

      • Variable Types

      • Variable Scope

    • Conditional Operators, Comparing < = > etc

    • Logical Operators 

    • For...Next Loop

    • Using Counters

    • If... Then... Else

    • Do...While Loops

    • Random Numbers

    • Val - converting strings to numeric data

    • Multiple Forms - creating backgrounds for your projects

    • Getting the user's name

    • Animation

    • Using the Timer Control

    • Measuring elapsed time

    • Activities

      • A First Program (Beep)

      • Die Rolling Simulation

      • Coin Flipping Simulation

      • Temperature Converter

     

     

     

     

 

 

This page has been produced by Margaret Meijers.  Questions or feedback may be directed by email to mmeijers at ictmindtools.net

  Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.
Attribution should include the statement: "This has been adapted from a resource originally created by Margaret Meijers at http://ictmindtools.net"