03 August, 2009

Session 5

* After the test we started working through Chapter 8, Using Procedures and Exception Handling.
* We talked about the fact that it's good to break your code into multiple small procedures so that they are easy to maintain and re-use.
* We recapped the difference between procedures and functions (a function returns a value).
* An example of procedure might be (the keyword sub tells us it is a procedure):
Public Sub MyProcedure()
'Do Something
End Sub
* An example of a function might be:
Public Function MyFunction() As Boolean
'Do Something
End Function
* Function is the keyword, MyFunction is the name, Boolean is the value.
* The data type or value stipulated depends on what the code is looking for.
* An example of a function is the IsNumeric function - it is a common task for which code has been written and added to the VB library so that it can be reused.
* We also briefly touched on the parameters ByVal and ByRef.
* When you enter arguments into a function, intellisense automatically adds in one of these parameters for each of the arguments.
* ByVal passes the actual object to the function (a duplicate is created), ByRef passes a reference to the object to the function.

No comments:

Post a Comment