PDA

View Full Version : Global Variabiles



LaoMa
05-27-2014, 02:35 AM
I'm tring to use a global variable, but I got some problems.
here the architeture of my VBA.

1. I create a Class Module named DatiVent

Option Explicit
Private m_Famiglia As String
private m_Name As string
.....

Public Property Get GetFamiglia() As String
Famiglia = m_Famiglia
End Property

Public Property Set SetFamiglia(value)
m_Famiglia = value
End Property

.....

2. then I create a Module named VarVENT where I create a public variable


Public VARIABILI As DatiVent

3. I'm tring to use the variable in a Form object:


VARIABILI.SetFamiglia ("PIPPO")


it dosen't work, I'm not an expert, This is the first time I'm using a more complex architeture, someone could help me?
thank you in advance

Bob Phillips
05-27-2014, 03:38 AM
Clas


Option Explicit

Private m_Famiglia As String
Private m_Name As String


Public Property Get Famiglia() As String
Famiglia = m_Famiglia
End Property

Public Property Let Famiglia(value As String)
m_Famiglia = value
End Property


managing module


Set VARIABILI = New DatiVent
VARIABILI.Famiglia = "PIPPO"
MsgBox VARIABILI.Famiglia

LaoMa
05-27-2014, 04:40 AM
Thank you XLD,

your suggestion works, but in that way the variables "VARIABILI" is only available in the object where I made the "SET", have you any ideas to made possible to read and write in the "VARIABILI" even outside his object?

thank you in advance

Bob Phillips
05-27-2014, 09:32 AM
You do read/write it outside of is object, as I showed in the managing module code, but you have to reference it via the object. That is the whole rationale of objects.