We will be undergoing scheduled maintenance on May 20th, 2013 at 02:00 GMT.
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Now that we've looked at subroutines, let's back up a second, and if you remember we are taking, we are actually taking a look at methods. Now if a subroutine is a method then what exactly is a function? Well as it turns out a function that's placed inside a class module again becomes a method when that class module is instantiated, or an object is instantiated off of it. Well if a function is a method and a subroutine is a method, what's the difference? Well a function is a subroutine that actually returns a value, that the only difference is that a function returns a value. Now let's look at the basic syntax of a function. Now we start off with putting a keyword function and we can use specifiers, you know private, public and so forth. And then we put the name of the function. And then we say as data type, now the data type that we put right here is a data type that's returned by the function. We can also take input parameters or input arguments on functions as well. Then we'll put code and we're virtually unlimited as to the code that we put here, we can take all kind of actions and then we'll finally return a value and we just put return value. Now if you are an old VB6'er, again if you remember you returned a value by putting the name of the function, you had to put the name of the function down here to return the value. That's gone in VB .NET. We can simply say return, and we put our particular value or a variable or something, then we simply end our function. And these things are real simple to write. But they can get really complicated and we can do as much complicated actions as we want to in there and then once it's all said and done come up with a value and return it back. These things are very, very powerful you see them used quite a bit. And again keep in mind all code in Visual Basic .NET has to either be encapsulated into a subroutine or function; now this is code that takes action or does something. And again a function just like a subroutine becomes a method and an instantiated object of a class.
| Course: | Microsoft Visual Basic .NET |
| Author: | Mark Long |
| SKU: | 33433 |
| ISBN: | 1932072349 |
| Release Date: | 2003-05-27 |
| Duration: | 6 hrs / 87 lessons |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |