VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Second Basic Note On Good Programming For Biggners

by Alive Softwares (3 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 26th January 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A Second Basic Note On Good Programming For Biggners

Rate A Second Basic Note On Good Programming For Biggners





There are two kinds of programming: good programming and bad programming.  Good programs are easy to follow and error free.  Bad programs are hard to understand and full of errors.  

Many inexperienced programmers will scoff at good programming concepts, thinking they are a silly waste of time. Nothing could be further from the truth.  


|-----------COMMENTS---------|

Commenting is a good programming practice. Not only do comments make it easier for you to follow your own program but if anyone else has to work with your code these comments can be invaluable.

In Basic, comments can start with the ' character or with the word REM. 

Comments do not affect the program, they are merely there to document what the code is doing.

                  |-----------STRUCTURED DESIGN-------------|

Good programs use structured design exclusively.  Structured design involves using control structures to control the flow of the program.  Examples of control structures include IF THEN conditions, loops and subroutines.

Bad programs use GOTO statements to jump around the code making program flow hard to follow.

In Visual Basic GOTO statements should only be used for error checking routines.  


         |-----------MODULARITY-------------|


Good programming makes use of modularity. Modularity involves designing programs as a collection of distinct modules.  

Breaking up a complex program into smaller chunks makes the program simpler and thus easier to design and maintain.

Programs are made modular by splitting code up into smaller code segments called subroutines.  Very large programs are further modularized by splitting the program up into libraries.

                          |----------SUBROUTINES---------|


Subroutines are independent sections of code.  

The main advantage of using subroutines is that code which is called several times in a program can be placed in a subroutine.  This subroutine can then be called anywhere in the program using a single line of code.  

Subroutines therefore not only dramatically reduce the number of lines of code in your program, but also tidy up the program making it easier to understand.

                  |------------CREATING SUBROUTINES------------|


In Basic there are two ways to create new sub procedures.  

Suppose we wanted to create a sub procedure to print out the current time.  We'll call this procedure "MyTime".  

The first way to create such a procedure would be to type:


sub MyTime



After pressing enter, you will find yourself inside the newly created sub procedure.


Sub MyTime ()

End Sub



The other way to create the Timer procedure would be to choose the "New Procedure" option from the "View" pull-down menu on the Visual Basic title bar.  



In the box that pops up type: 

MyTime

and then press the [Enter] key or click on the [OK] button.


Enter this line between the SUB MyTime and END SUB lines:



  MsgBox "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

Download this snippet    Add to My Saved Code

A Second Basic Note On Good Programming For Biggners Comments

No comments have been posted about A Second Basic Note On Good Programming For Biggners. Why not be the first to post a comment about A Second Basic Note On Good Programming For Biggners.

Post your comment

Subject:
Message:
0/1000 characters