-
array property of a class object - Excel Help & Excel Macro Help
Thread Tools Search this Thread
#1 Users Attachments
Old February 23rd, 2005
Intelligent Converters
Add our expertise to your Google search results FREE DOWNLOADS
File/Password Recovery
svuille svuille is offline
I agreed to these rules
I'm a Spammer:
MS Office Version: 2000
Op System: Windows XP
Assumed Experience: Mainly VBA
Join Date: 2nd February 2005
English is 1st Language:
Posts: 14 -- Threads: 7
array property of a class object
Hi again everyone at Ozgrid.
I have a question regarding the creation of array properties in class objects. I am currently working on wrapping the bloomberg API calls in a class object. The main parameters needed by the API are two arrays, one for the bloomberg tickers, and one for the bloomberg fields. Based on a previous post about classes and array propertied, the class module I am working on looks like this:
VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred when copy/pasting, but IS if the keyword uses "quotes".
'Excel Class Wrapper Example 'Sam Jacob / Bloomberg, London 'modified by simon vuille 'Object variable to hold a reference to the Bloomberg data control Private WithEvents oBBG As BLP_DATA_CTRLLib.BlpData 'member variable to hold sheet reference (to which data will be written back), 'as well as array properties Private m_sheetref As Worksheet Private m_BBTickers() As String Private m_BBFields() As String 'The field property, read/write array Public Property Let BBFields(Index As Integer, Value As String) m_BBFields(Index) = Value End Property Public Property Get BBFields(Index As Integer) As String BBFields = m_BBFields(Index) End Property 'The tickers property, read write array Public Property Let BBTickers(Index As Integer, Value As String) m_BBTickers = Value End Property Public Property Get BBTickers(Index As Integer) As String BBTickers = m_BBTickers(Index) End Property Public Property Let Datasheet(nsheet As Worksheet) 'set's the sheet to which data is written back Set m_sheetref = nsheet End Proper -
Classes In VBA
-
Using Classes In Multiple Projects
If the Instancing property of the class is PublicNotCreatable a variable
of that class type may be declared in other projects, but cannot be created in that project. You can use a function in the project
containing the class to return a new instance to the caller. First, change the name of the project containing the class from the default value
of VBProject to something meaningful like projSourceProject. Then, in the class that
will use the class, set a reference to projSourceProject. Back in the project containing the class, create a
procedure that will create and return a new instance of the class:
Public Function GetClass() As CEmployee
Set GetClass = New CEmployee
End Function
Then call this function in the project that will use the class:
Dim NewEmp As projSourceProject.CEmployee
Set NewEmp = projSourceProject.GetClass()
-
