Solved

A public variable Within Classes in DLL

Posted on 2002-07-17
6
156 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 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