I'm trying to make an array global within a project, so that different modules can use it. I was thinking the best way to do this would be to create a class which contains the array as a private variable which can be accessed through the property set and get methods. I no how I would do this in c++, but I'm new to vb/vba and I'm not sure how to do this. I'd like the array to be automatically initialized to some values when the object is constructed. So far I'm having two problems:
1. I can't figure out how to build a constructor. I tried:
Private Sub myClass_Initialize()
msgbox "constructor called"
End Sub
... and nothing happened when I called this code in another module:
Dim myobj as myClass
Set myobj = New myClass
myobj.someMethod
where someMethod does nothing
2. Can't get Static Variables to work. I wrote these two methods:
Public Sub showint()
MsgBox myint
End Sub
Public Sub yo()
Static myint As Integer
myint = 15
End Sub
And called them in a procedure in another module like this:
myobj.yo
myObj.showint
The result was that a blank dialog box, not showing myint, was displayed.
So what am I missing? btw, I'm using vba with Outlook 2000.
-Venkman
1. I can't figure out how to build a constructor. I tried:
Private Sub myClass_Initialize()
msgbox "constructor called"
End Sub
... and nothing happened when I called this code in another module:
Dim myobj as myClass
Set myobj = New myClass
myobj.someMethod
where someMethod does nothing
2. Can't get Static Variables to work. I wrote these two methods:
Public Sub showint()
MsgBox myint
End Sub
Public Sub yo()
Static myint As Integer
myint = 15
End Sub
And called them in a procedure in another module like this:
myobj.yo
myObj.showint
The result was that a blank dialog box, not showing myint, was displayed.
So what am I missing? btw, I'm using vba with Outlook 2000.
-Venkman