by Frank Stone » Tue Feb 20, 2007 4: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