Computer Science Canada

[tutorial] procedures

Author:  Tony [ Sun Sep 15, 2002 4:21 pm ]
Post subject:  [tutorial] procedures

I'm quite new to the VB at this point, and it took me a while to find out how to use procedures. In case you're new to this stuff too, a procedure is a piece of code that you can execute over and over again without typing it up all over the place. It keeps things more organized and reduces the size of the file too Wink

It is decleared just like any other event
code:
Private Sub name(text As String)
Print text
End Sub


Above is a procedure called name that takes in a single string paramited and stores it in local variable called text.

Now you can use the above code just by calling up the procedure by using call and its name as in code below:

code:

Private Sub cmd_button_Click()
Call name("tony")
End Sub


above is the code behind a button and it will call up a procedure name and send in tony as a parameter so the name "tony" will be printed on screen each time you press the button Very Happy

I hope this helps with your programs.


: