• 0
Lesiastas

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

Question

Posted (edited)

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

Edited by Lesiastas
Wrong Grammar

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now