Test and Measurement Forum


Post your VB and VBA discussions here


Postby Frank Stone » Tue Jan 02, 2007 12:18 pm

removed fjs
Last edited by Frank Stone on Thu Jan 04, 2007 9:35 am, edited 1 time in total.
Frank Stone
Posts: 4
Joined: Tue Jan 02, 2007 12:07 pm

Postby Frank Stone » Wed Jan 03, 2007 9:59 am

What was I doing??

I am trying to use the PS3000_get_unit_info function in VB6.0. When I step into the Call the VB editor is totally deleted.

In the PS3000.xl example, which uses VBA Macro, this call is located in a For-Next loop all of which are Commented-Out. I've change this macro code by un-commenting this code but this booms out as well.

Can anyone help?
Frank Stone
Posts: 4
Joined: Tue Jan 02, 2007 12:07 pm

Postby ziko » Tue Feb 20, 2007 1:30 pm

Hi and thank you for your post.

We have recently looked into this and to fix this problem you need to change the string length from 255 to 40.


Dim S As String * 40


j = ps3000_get_unit_info(ps3000_handle, S, 40, i)

hope this helps.

Kind regards

Technical Specialist
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Postby Frank Stone » Tue Feb 20, 2007 3:32 pm

The File PS3000.BAS is issued with a fundamental defect in it:
Declare Function ps3000_get_unit_info Lib "ps3000.dll" (ByVal handle As Integer, str As String, ByVal lth As Integer, ByVal line_no As Integer) As Integer

In Vbasic the str is a named function which returns a String representation of a number. Therefore, it should not be used for the name of any other variable.
By default Vbasic will take the declared str As String, as a ByRef. Which indicates that the argument is passed by reference to the variable name i.e. str

Needless to say Vbasic does not like this at all.

A quick fix is to add the ByVal key word in front thus:- ByVal str as String. Now it is the value of the string passed to it in the call that is used, which of course should be different name like (RetStr) . Of course it should not be the Null String so it must be allocates storage space with fixed-length string statement
[Dim RetStr as string * 255] before it can be used in the call.

Dim RetStr As String * 255, LenRet As Integer, Info As Integer
LenRet = 255 ' or => 12
Info = 0 ' for Driver version
Info = 1 'for USB Version
Info = 2 'for Hardware Version
' to
Info = 5 'for Cal Date
Info = 6 'for Error code

OK = ps3000_get_unit_info(ps3000_handle, RetStr, LenRet, Info)
If OK = 0 Then Error
Text1.text = RetStr + vbcrlf
Frank Stone
Posts: 4
Joined: Tue Jan 02, 2007 12:07 pm

Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests