I'm trying to write code for a USBTC-08 (2 units) in Visual Basic 2010 Windows XP using the latest usbtc08.dll. The sample VB6 code that came with the drivers from Pico works fine. But I can't get all the functions to work in VB.NET. Specifically, the functions: usb_tc08_get_unit_info2, usb_tc08_get_formatted_info and usb_tc08_get_single are not returning any data. The function results come back as 1 (good), but there is no information. Can anyone share a few lines of sample code in VB.NET showing how they got these functions to work? Thank you!
You need to make sure that the Function Declarations are correct, in particular strings need to be passed as ByVal even if they are there to receive data. They should be populated as a string of spaces of sufficient length to receive the expected data before use. Any enumerated constants should be longs and not integers.
Thank you. Everything works now except usb_tc08_get_single. Please take a close look at my code and let me know what I am doing wrong. The program crashes at the usb_tc08_get_single function.
Declare Function usb_tc08_get_single Lib "c:\PICO\usbtc08.dll" (ByVal handle As Integer, ByRef temp() As Single, ByRef overflow_flags As Integer, ByVal units As Integer) As Long
Private Sub getUSBTC08()
Dim unitResult As Long
Dim handle As Integer = 1
Dim tempReadings(9) As Single
Dim ofFlag As Integer
Dim tempUnits As Integer = 1
For n = 0 To 8
unitResult = usb_tc08_set_channel(handle, n, "K")
Debug.Print(unitResult)
Next
unitResult = usb_tc08_get_single(handle, tempReadings, ofFlag, tempUnits)
Debug.Print(unitResult & " " & ofFlag)
For n = 0 To 8
Debug.Print(tempReadings(n))
Next
End Sub
Thank you. I had already tried this. It gives an error in VB.NET (won't compile). Has anyone had any success with this? Please offer corrections to my code. Thank you!
Declare Function usb_tc08_get_single Lib "c:\PICO\usbtc08.dll" (ByVal handle As Integer, ByRef temp As Single, ByRef overflow_flags As Integer, ByVal units As Integer) As Long
The following code give me a "...may be inaccessible due to protection level" error on line 54 ... can you tell me how to fix it? Please send an email.