Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Test LabJack U12 with Visual basic 2008


  • Please log in to reply
1 reply to this topic

#1 idir

idir
  • Members
  • 1 posts

Posted 13 February 2013 - 09:53 AM

Hello, I try run this program with Labajack (see the program in the bottom) The compilation generate no errors But the program dosen't work. Please, I need Help Thanks you Idir ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Public Class Form15 'Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'End Sub Private Declare Function EAnalogIn Lib "ljackuw.dll" _ (ByRef lpIDNum As Long, _ ByVal lngDemo As Long, _ ByVal alngChannel As Long, _ ByVal alngGain As Long, _ ByRef lngOverVoltage As Long, _ ByRef asngVoltages As Single) As Long '================================ Private Declare Function EDigitalIn Lib "ljackuw.dll" _ (ByRef lpIDNum As Long, _ ByVal lngDemo As Long, _ ByVal alngChannel As Long, _ ByVal alngReadD As Long, _ ByRef lngState As Long) As Long '=================================== Private Declare Function EDigitalOut Lib "ljackuw.dll" _ (ByRef lpIDNum As Long, _ ByVal lngDemo As Long, _ ByVal alngChannel As Long, _ ByVal alngWriteD As Long, _ ByVal lngState As Long) As Long Private Sub CMD2OFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMD2OFF.Click Dim ChannelSelected, stateD, lngErrorcode As Long 'set digital output channel2 OFF ( i.e. 0V ) ChannelSelected = 2 '0=IO0, 1=IO1, 2=IO2, 3=IO3 stateD = 0 lngErrorcode = EDigitalOut(-1, 0, ChannelSelected, 0, stateD) CheckBox1.Checked = False End Sub '------------------------------------------------------------------------------------- Private Sub CMD2ON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMD2ON.Click Dim ChannelSelected, stateD, lngErrorcode As Long 'set digital output channel2 ON ( i.e. 5V ) ChannelSelected = 2 '0=IO0, 1=IO1, 2=IO2, 3=IO3 stateD = 1 lngErrorcode = EDigitalOut(-1, 0, ChannelSelected, 0, stateD) CheckBox1.Checked = True End Sub '------------------------------------------------------------------------------------- Private Sub CMD3OFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMD3OFF.Click Dim ChannelSelected, stateD, lngErrorcode As Long 'set digital output channel3 OFF ( i.e. 0V ) ChannelSelected = 3 '0=IO0, 1=IO1, 2=IO2, 3=IO3 stateD = 0 lngErrorcode = EDigitalOut(-1, 0, ChannelSelected, 0, stateD) CheckBox2.Checked = False End Sub '------------------------------------------------------------------------------------- Private Sub CMD3ON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMD3ON.Click Dim ChannelSelected, stateD, lngErrorcode As Long 'set digital output channel 3 ON (i.e. 5V ) ChannelSelected = 3 '0=IO0 , 1=IO1, 2=IO2, 3=IO3 stateD = 1 lngErrorcode = EDigitalOut(-1, 0, ChannelSelected, 0, stateD) CheckBox2.Checked = True End Sub '------------------------------------------------------------------------------------- Private Sub Timer1_Timer() Dim lngErrorcode As Long 'Dim strError As String * 50 Dim overvoltage As Long Dim VoltageAI0 As Single Dim VoltageAI1 As Single Dim ChannelSelected As Long Dim stateD As Long Dim BarWidth As Single ' Read analogue input AI0. Value will be stored in voltageA0 ChannelSelected = 0 lngErrorcode = EAnalogIn(-1, 0, ChannelSelected, 0, overvoltage, VoltageAI0) ' Read analogue input AI1. Value will be stored in VoltageAI1 ChannelSelected = 1 lngErrorcode = EAnalogIn(-1, 0, ChannelSelected, 0, overvoltage, VoltageAI1) '++++++++++++++++++++++++++++++++++++++++++ 'Decipher error code if any and set appropriate textbox 'GetErrorString(lngErrorcode, strError) 'LblError.Caption = StrError 'Set bargraph displays ' max width from properties is 3255. Decided by drawing the full length ' of bar then checking the width property. The following code prevents the ' barwidth becomming zero or less BarWidth = Int((VoltageAI0 / 5) * 3255) If BarWidth < 1 Then BarA0.Width = 1 Else BarA0.Width = BarWidth End If TXTA0.Text = Str(VoltageAI0) + " Volts " 'using a text box for display here BarWidth = Int((VoltageAI1 / 5) * 3255) If BarWidth < 1 Then BarA1.Width = 1 Else BarA1.Width = BarWidth End If LblA1.Text = VoltageAI1 'using a label box for display here '++++++++++++++++++++++++++++++++++++++++++++++++++ 'Read state of digital input channel 1 and store result ( 0/1) in stateD ChannelSelected = 1 ' 0 = IO0 , 1 = IO1, 2 = IO2, 3 = IO3 lngErrorcode = EDigitalIn(-1, 0, ChannelSelected, 0, stateD) ' display the state of digital channel 1 ( switch closed or open ) If stateD = 0 Then Label6.Text = "OFF" Else Label6.Text = "ON" '++++++++++++++++++++++++++++++++++++++++++++++++++++ 'Read state of digital input channel 0 and store result ( 0/1) in stateD ChannelSelected = 0 ' 0=IO0 , 1=IO1, 2=IO2, 3=IO3 lngErrorcode = EDigitalIn(-1, 0, ChannelSelected, 0, stateD) ' display the state of channel 0 (switch closed or open ) If stateD = 0 Then Label2.Text = "OFF" Else Label2.Text = "ON" '+++++++++++++++++++++++++++++++++ End Sub End Class

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 February 2013 - 10:47 AM

What sort of problem are you having? What does the program do or not do? One thing I notice is that I don't see any errorchecking. Every call to the U12 driver returns an errorcode. You should look at these and if any are nonzero do something.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users