Hello, i’m new to programing but picking it up pretty fast for what I need. I have a program that I am trying to display an analog count to a label. I am using visual studio vb.net compiler. I wrote code that will read the analog channel but only takes an initial reading and does not update continuously. I have not found an event that works like the demo for the label control. I can set a .click event but I have to click the label every time I want to update the value. From what I have went through in the demo somehow they have set a .valuechanged event for a scrollbar and displayed the value in a label I believe. In my program I just want a label box to display the current reading in realtime. I have tried loops but they lock my program up. My code follows.
Public Class FormRpsi
Inherits System.Windows.Forms.Form
Dim bDoNothing As Boolean
Dim shtCount As Short
Dim intCardNumber As Integer
Private Declare Function OpenDevice Lib "k8061.dll" () As Integer
Private Declare Sub CloseDevices Lib "k8061.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer) As Integer
Private Declare Function PowerGood Lib "k8061.dll" (ByVal intCardNumber As Integer) As Boolean
Private Declare Function Connected Lib "k8061.dll" (ByVal intCardNumber As Integer) As Boolean
Private Declare Sub ReadVersion Lib "k8061.dll" (ByVal intCardNumber As Integer, ByRef Buffer As Integer)
Private Declare Sub ReadAllAnalog Lib "k8061.dll" (ByVal intCardNumber As Integer, ByRef Buffer As Integer)
Private Declare Sub OutputAnalogChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer, ByVal Data As Integer)
Private Declare Sub OutputAllAnalog Lib "k8061.dll" (ByVal intCardNumber As Integer, ByRef Buffer As Integer)
Private Declare Sub ClearAnalogChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer)
Private Declare Sub SetAllAnalog Lib "k8061.dll" (ByVal intCardNumber As Integer)
Private Declare Sub ClearAllAnalog Lib "k8061.dll" (ByVal intCardNumber As Integer)
Private Declare Sub SetAnalogChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer)
Private Declare Sub OutputAllDigital Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Data As Integer)
Private Declare Sub ClearDigitalChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer)
Private Declare Sub ClearAllDigital Lib "k8061.dll" (ByVal intCardNumber As Integer)
Private Declare Sub SetDigitalChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer)
Private Declare Sub SetAllDigital Lib "k8061.dll" (ByVal intCardNumber As Integer)
Private Declare Function ReadDigitalChannel Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Channel As Integer) As Boolean
Private Declare Function ReadAllDigital Lib "k8061.dll" (ByVal intCardNumber As Integer) As Integer
Private Declare Sub OutputPWM Lib "k8061.dll" (ByVal intCardNumber As Integer, ByVal Data As Integer)
Private Declare Sub Version Lib "k8061.dll" ()
Private Sub ButtonRraise_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ButtonRraise.MouseDown
SetDigitalChannel(0, 1)
End Sub
Private Sub ButtonRraise_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ButtonRraise.MouseUp
ClearDigitalChannel(0, 1)
End Sub
Private Sub ButtonRlower_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ButtonRlower.MouseDown
SetDigitalChannel(0, 2)
End Sub
Private Sub ButtonRlower_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ButtonRlower.MouseUp
ClearDigitalChannel(0, 2)
End Sub
[u] Private Sub lblrpsi_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblrpsi.TextChanged
Dim rpsi As Integer
rpsi = ReadAnalogChannel(0, 1)
lblrpsi.Text = rpsi
End Sub[/u]
End Class
The area underlined is the part I’m working on, the rest works fine.