Solved

A public variable Within Classes in DLL

Posted on 2002-07-17
6
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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