Solved

A public variable Within Classes in DLL

Posted on 2002-07-17
6
155 Views
Last Modified: 2010-05-02
I want to use a public variable in my Activex project, I need that all my calsses will "see" the variable but he wont be visible outside to projects that using my DLL.

Something like "Public DLL" variable.

Can I do it ?

0
Comment
Question by:computech1
6 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 7159213
Hi,
   Well It would be nice to have a property instead of public variable.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7159238
You will want to use a property and declare it as Friend.  This will give all classes access to the property, but no one outside the DLL.

Friend Property Get IntValue() As Variant

End Property

Friend Property Let IntValue(ByVal vNewValue As Variant)

End Property
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 20 total points
ID: 7159273
Put you valuable on module
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 26

Expert Comment

by:EDDYKT
ID: 7159276
Define your valuable in module.

I can't see my last comment even I reload the question. Strange?
0
 
LVL 4

Expert Comment

by:gencross
ID: 7159278
This property will go in the class module.
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7159286
Add a General Module to your DLL project and declare a public variable in it. Like this:

'this goes in the general module of the DLL
Public xt As Integer

Sub Main()
xt = 5
End Sub

Therefore the startup form of your dll project will be Sub main

In the class module , you can access this value
Function mytest() As Integer
MsgBox xt
mytest = 1
'or you assign the value to mytest function
End Function

-------------------------

Therefore when you call this dll after you make an object,..

'In standard exe

Dim p As New pr.Class1
Private Sub Command1_Click()
p.mytest
End sub

Hope this helps!!

-priya

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now