Jump to content
  • 0

VBA Equivalent of "<MarshalAs(UnmanagedType.LPArray)>" in calling DigitalOut APIs in MS Excel


Lesiastas

Question

Greetings,

I am creating a VBA program which uses the DigitalOut Functions in the dwf.vb file to replicate the capability of the AD2's Pattern Generator.
I'm having trouble of declaring the FDwfDigitalOutDataSet API in VBA. I always encounter this error:

image.png.57c14e4f5e4693d7a06dc1dc86bb1dc4.png

I am aware that this is because of some data types in VB6 that are not supported in VBA. I've encountered similar errors in the FDwfDigitalOutRepeatSet and the FDwfDigitalOutDividerSet API. What I did was change the UInteger data type to Integer, since its the data type supported supported in VBA. 

Function FDwfDigitalOutRepeatSet(ByVal hdwf As Integer, ByVal cRepeat As Integer) As Integer
    End Function

Function FDwfDigitalOutDividerSet(ByVal hdwf As Integer, ByVal idxChannel As Integer, ByVal v As Integer) As Integer
    End Function

 

I already changed countOfBits in FDwfDigitalOutDataSet from UInteger to Integer, but the error is still present. I think the error is because of the <MarshalAs(UnmanagedType.LPArray)> used in the FDwfDigitalOutDataSet.
What changes could I do to FDwfDigitalOutDataSet in order to agree with VBA? 

 Function FDwfDigitalOutDataSet(ByVal hdwf As Integer, ByVal idxChannel As Integer, <MarshalAs(UnmanagedType.LPArray)> rgBits() As Byte, ByVal countOfBits As Integer) As Integer
    End Function

Sorry in advance, but I could be wrong since I'm a complete novice in coding, especially across different programming platforms. Any advice on how to work around this?

Regards, 

Lesiastas

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...