![]() |
|
VB6 - Basics 4 - What's the function of that sub? - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Programming (https://mirage-engine.uk/forums/forumdisplay.php?fid=24) +---- Thread: VB6 - Basics 4 - What's the function of that sub? (/showthread.php?tid=2894) |
VB6 - Basics 4 - What's the function of that sub? - Jacob - 29-06-2009 Subs and function are the backbone of the program. A function will return a value and a sub will not. Sub Code: Public Sub Foo()Function It is advised to give a return variable to your function. Below will return a Long variable. Code: Public Function Foo() as LongByVal and ByRef ByVal: ByValue - will make a local copy of the variable. Meaning if you change the value you are not changing the original value. ByRef: By Reference - It is similar to a pointer in c++. If you change the value of the variable, the original value will change. Optional An optional argument is just that, you don't have to pass anything into that sub or function. When declaring an optional argument, it is best practice to give it a default value. Code: Public Function Foo(Optional ByVal val As Long = 1) As LongProject Code: Private Sub Command1_Click()What will 'i' and 'ii' equal ? Explain why they will equal what they do. Now program a small calculator. You must be able to input any 2 numbers and use all basic math operators (+,-,/,*). The user must be able to pick what mathematical operator to use. Overview
Notes
Re: VB6 - Basics 4 - What's the function of that sub? - Pbcrazy - 29-06-2009 Very nice tuts! But if i may suggest, put all of these into a seperate sub-board. Like VB6 Basic's or something. Re: VB6 - Basics 4 - What's the function of that sub? - Pbcrazy - 29-06-2009 Please don't tell me I have to complete them... But i agree with Asrrin none the less. |