TC08 VB.NET problem possibly with datatypes

Having problems ? let us know the details here
Post Reply
homer
User
User
Posts: 2
Joined: Wed Feb 27, 2019 9:47 am

TC08 VB.NET problem possibly with datatypes

Post by homer »

I am writing code for TC08 in VB.NET
I have written a very simple program in VB6 that works 100%
However, if I try to use exactly the same code in VB.NET (adjusted obviously for differences in syntax and language constraints) when trying to retrieve all 8 channels I gate the same Cold Junction temperature returned for ALL channels (unlike the VB6 version which performs as required)
I suspect it is something to do with the data type differences between VB6 and VB.NET.
In VB.NET...……..

Public temperature() As Single

some more code etc

ReDim temperature(9)

set mains etc...…….. here.

' activates CJ channel
Status = usb_tc08_set_channel(usbTC08HandleA, 0, Asc("R"))

'reads temp of cold junction
Status = usb_tc08_get_single(usbTC08HandleA, temperature(0), overflow_flag, 0)
If Status > 0 Then
Label1.Text = Label1.Text + vbCrLf + "CJ=" + CStr(temperature(0))
Else
Label1.Text = Label1.Text + "CJ failed to read"
End If

'set channel 'zone' as enabled
Dim zone As Integer
For zone = 1 To 8
Status = usb_tc08_set_channel(usbTC08HandleA, zone, Asc("R"))
Status = usb_tc08_get_single(usbTC08HandleA, temperature(zone), overflow_flag, 0)
Next

' read all 8 channels
status = usb_tc08_get_single(usbTC08HandleA, temperature(0), overflow_flag, 0)

This structure works perfectly in VB6 but not VB.NET?
After above call, the array temperature() contains (say)
temperature(0) 20.1234
temperature(1) 20.6357
temperature(2) 20.8373
etc etc
temperature(8) 20.2323

in VB6 ………..
temperature(0) 20.1234
temperature(1) 1020.34
temperature(2) 1040.23
etc etc
temperature(8) 999.456
Any ideas?

homer
User
User
Posts: 2
Joined: Wed Feb 27, 2019 9:47 am

Re: TC08 VB.NET problem possibly with datatypes

Post by homer »

Have based my coder on the GitHub sample.

Post Reply