Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2007, 11:38 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

A variable dimmed within a routine has scope only for that routine. You can pass it to another routine as a reference, but that reference will have scope only in the called routine. If it is an effective reference, the variable in the calling routine will hav eits value changed if the value of the reference is changed in the called routine.

A variable Dimmed within a routine never has scope outside the routine, but if it is created with the keyword Static, it will retain its value between calls to the routine, so that in this special case it will have life beyond the life of the routine, but scope only within the routine itself.

A variable dimmed within the code of a form has scope for the whole form if Private, and can be accessed from outside the form if Public or Global (Public is preferred) when specified in a fully qualified fashion.

The variable will go out of existence if the form is closed/unloaded. Hiding the form will not terminate the variable; it will retain its value.

A variable dimmed in a Class will behave exactly the same, inasmuch as a form is a specialized class.

A variable dimmed in a Module as public will be available to the entire project—objects, forms, other modules, everywhere—and will have life for the life of the application.
A variable dimmed in a Module as private will be available only to the code within that module. There is no way to access it from outside the module's code, but a routine within that module can pass the value of the private variable out to other processes in the following fashion:
Code:
Private pvtString As String

Public Function PassString() As String
    PassString = pvtString   ' Passes the value by changing the
                             ' value of the Function
End Function

Public Sub Pass_String(ByRef TheVal As String)
    TheVal  = pvtString      ' Passes the value by changing the 
                             ' value of the reference variable
End Sub
How big is this project?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Flow chart of Cobol program in dotNet SOANS General .NET 0 November 20th, 2007 11:29 PM
Flow of the Program ? pandian Java Basics 2 March 20th, 2006 11:07 PM
weird program flow with nested functions zayasv General .NET 1 January 6th, 2006 11:06 AM
weird program flow with nested loops zayasv Intro Programming 2 November 17th, 2005 06:19 AM
weird program flow with nested functions zayasv VB.NET 0 October 26th, 2005 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.