Get the count of elements currently selected using VBA

Hi all,

I would like to get the count of the number of elements selected in MicroStation VBA.

I have already used a scan criteria to get the elements I want. Now the issue is that I would then iterate through the selected elements using the ElementEnumerator, and add up all the lengths of the LineElements in my selection set.

I know I can get the total length of the selected elements using CommandState.MeasureResult1. 

I want to also get the count or number of selected elements.

Before i was using 

Dim elmCount As Long
elmCount = UBound(ActiveModelReference.GetSelectedElements.BuildArrayFromContents) +1

This works, but I imagine it might not be optimal.

I have also explored mdlSelect_numSelected() function by calling it from my VBA code, 

'Declared Mdl function
Declare Function mdlSelect_numSelected Lib "stdmdlbltin.dll" (ByVal windowP As Long) As Long

Dim windowPval As Long
Dim elmCount As Long

windowPval = 1
elmCount = mdlSelect_numSelected(windowPval)

sample dgn

The image i attached shows the two values i am trying to obtain from within my VBA code.

The code i used above with the Declare statement doesn't work as i get an error 

Run-time error '49':

Bad DLL calling convention

This is the error i am getting. 

I'm not sure what i need to pass the mdlSelect_numSelected() as an argument as my VBE editor suggested a 

Long
as an argument.

I am currently using MicroStation V8i SS4, version 08.11.09.829, on Windows 10, build 1809, 64bit.

Thank you.