PS300_get_unit_info

 
Post new topic   Reply to topic    Pico Technology Forum Index -> VB and VBA (Excel, Access)
Author Message
Frank Stone
User
User


Joined: 02 Jan 2007
Posts: 4

PostPosted: Tue Jan 02, 2007 12:18 pm    Post subject: PS300_get_unit_info Reply with quote

removed fjs

Last edited by Frank Stone on Thu Jan 04, 2007 9:35 am; edited 1 time in total
Back to top
Frank Stone
User
User


Joined: 02 Jan 2007
Posts: 4

PostPosted: Wed Jan 03, 2007 9:59 am    Post subject: Reply with quote

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?
Back to top
ziko
Site Admin
Site Admin


Joined: 01 Dec 2006
Posts: 606
Location: St Neots

PostPosted: Tue Feb 20, 2007 1:30 pm    Post subject: Reply with quote

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.

i.e.

Dim S As String * 40

and

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

hope this helps.

Kind regards
Back to top
Frank Stone
User
User


Joined: 02 Jan 2007
Posts: 4

PostPosted: Tue Feb 20, 2007 3:32 pm    Post subject: Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Pico Technology Forum Index -> VB and VBA (Excel, Access)
All times are GMT
Page 1 of 1

 


Pico Technology topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group