Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [tutorial] procedures
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: