Modular Programming

Up to this point you should be thinking that you know more then enough VB knowledge to make efficient programs. Well your actually missing one thing, thats why i have dedicated this section to Modular Programming (.bas files). The best way to code is to write small codes, they're easier to read, you can find bugs easier, therefore the better, more reliable programs you will make.

modular programming preview

Tip: This way of programming is called Structured Programming, its just a method where you break up program codes into small procedures

Here 's an example of why you would want to use Structured programming in your program:

Private Sub Command1_Click()

    Call User_Name

    Call UserID

End Sub

This code, if it wasn't structured would take more then two lines of code to do. Not only will it be shorter, but you would be able to use it throughout your program w/o having to rewrite the code or copy & pasteing the User_Name & UserID codes.

Note: The "Call" Keyword just triggers the execution of another procedure, meaning that you would have User_Name & UserID defined in your .bas

If you have ever DLed a bas from a site, then you probably have noticed the keywords Private & Public... The Private keyword limits the calling of a procedure within that module. The Public keyword doesn't limit the calling of a procedure, and therefore can be called from anywhere in that project.

Subroutines work when they are called by other procedures, but do not return values

Functions work when they are called by other procedures, and return values (such as described in previous section)

Calling a Subroutine

Call Names () Calling a Function

Call DoTax (Tax As TextBox) As Integer

This really just covers the basics, I will add to it soon enough... For now move on...


Functions                                   Writing to files