excel - Extracting a Specific Variable from a Class Module in VBA to a Standard Module -


all, following code bloomberg. designed extract bulk data servers. code works, trying extract specific variable generated in class module , bring regular module user defined functions. help.

option explicit private withevents session blpapicomlib2.session dim refdataservice blpapicomlib2.service  private sub class_initialize() set session = new blpapicomlib2.session session.queueevents = true session.start session.openservice ("//blp/refdata") set refdataservice = session.getservice("//blp/refdata") end sub  public sub makerequest(sseclist string) dim sfldlist variant dim req request dim nrow long sfldlist = "call_schedule" set req = refdataservice.createrequest("referencedatarequest") 'request type req.getelement("securities").appendvalue (sseclist) 'security + field string array req.getelement("fields").appendvalue (sfldlist) 'field string var dim cid blpapicomlib2.correlationid set cid = session.sendrequest(req) end sub  public sub session_processevent(byval obj object) dim eventobj blpapicomlib2.event set eventobj = obj if application.ready     if eventobj.eventtype = partial_response or eventobj.eventtype = response         dim blpapicomlib2.messageiterator         set = eventobj.createmessageiterator()         while it.next()             dim msg message             set msg = it.message                 dim security element                 set security = msg.getelement("securitydata").getvalue(0)                 sheet1.cells(4, 4).value = security.getelement("security").value                 dim fieldarray element                 set fieldarray = security.getelement("fielddata")                     dim field blpapicomlib2.element                     set field = fieldarray.getelement(0)                     if field.datatype = 15                         dim numbulkvalues long                         numbulkvalues = field.numvalues '76                         dim index long                         index = 0 numbulkvalues - 1                             dim bulkelement blpapicomlib2.element                             set bulkelement = field.getvalue(index)                             dim numbulkelements integer                             numbulkelements = bulkelement.numelements '2 elements per each pt                             redim call_sch(0 numbulkvalues - 1, 0 numbulkelements - 1) variant                             dim ind2 long                             ind2 = 0 numbulkelements - 1                                 dim elem blpapicomlib2.element                                 set elem = bulkelement.getelement(ind2)                                 call_sch(index,ind2)=elem.value                                 sheet1.cells(index + 4, ind2 + 5) = elem.value                             next ind2                         next index                     else                     call_sch(index,ind2)=field.value                         sheet1.cells(index + 4, ind2 + 5).value = field.value                     end if         loop     end if end if end sub 

the variable trying get, specifically, call_sch. want function in main module recognize variable. again.

it isn't necessary declare variable before using redim on it; redim can declare variable. however, if added:

public call_sch() variant ' insert correct data type here 

then able refer via:

<yourclassvaraiblename>.call_sch  

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -