VISUAL BASIC TIP | |||
Code | VBTPFUN002 | ||
Description |
USING PROCEDURE-LEVEL VARIABLE ACROSS THE PROCEDURES. | ||
VB Version Compatibility |
This solution works in VB4,VB5,VB6 & VBA (Visual Basic For Application). | ||
THEORY |
If you want to exchange information between Procedures in a particular Module then one or the way of doing it that you need to declare a Module-Level variable. A Module-Level variable is available within the module to all the procedures. But there are certain drawback using Module-Level variable like You do not know which procedure changes it value and another important factor is memory Module-Level variable has the same life as the Module and consume memory till Module is loaded in memory. To avoid using Module-Level variable you can declare Procedure-Level variables and exchange information between procedures using ByRef way of passing Arguments. Passing Arguments using ByRef keyword gives the procedure access to the actual variable contents in the memory address location. Due to this a variable's value can be changed by the procedure it passed in. It is the default way of passing Argument and you do not have to specify ByRef Keyword. | ||
TIP |
|
--------------------X-X-X-X-X-X-X-X--------------------
SPECIAL NOTE :- This tip is tested thoroughly. Use this tip is your own risk. Visual Code is not responsible for any damage caused directly or indirectly. |