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 January 19th, 2004, 11:44 PM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Default Shared Variable between instant object.

How can I share variable between instant objects that come from the same class in VB6. ?
Is there "Shared" keyword in VB6. like there is in VB.Net ?
Thanks in advance .

 
Old January 20th, 2004, 05:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can not declare a variable as shared, however you can declare a procedure as shared by using the Friend keyword instead of Private or Public. You could therefore write a Get/Let procedure pare that can retrieve and set the variable you want to share, here is a simple example:

Code:
Dim lngTest As Long

Friend Property Get Test() As Long

    Test = lngTest

End Property

Friend Property Let Test(ByVal newTest As Long)

    lngTest = newTest

End Property
The property will be available to everything in your project that uses the class, however the calling program will not be able to retrieve or set the property.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared variable problem in Crystal Reports 8.5 mjk6035 Crystal Reports 1 October 20th, 2008 09:10 AM
object reference not set to instant of an object shahidrasul ASP.NET 2.0 Basics 1 September 5th, 2008 02:01 PM
Local Shared object in flash charu Flash (all versions) 1 July 1st, 2005 11:03 AM
difference b/w shared and public variable lgeetha VS.NET 2002/2003 1 March 4th, 2005 08:24 AM
shared variable problem narooma.12 Crystal Reports 1 November 2nd, 2004 10:45 PM





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