Guest User

Untitled

a guest
Feb 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.50 KB | None | 0 0
  1. 'This is the call from the polling thread
  2. myPoint.SetCurrentValue(singleAry(.PointUDFs("ModuleIndex")._Value))
  3.  
  4. 'This is the event def in the Point
  5. Event ValueChanged(ByVal NewValue As Double, ByVal DisplayNormal As String, ByVal UnitText As String)
  6.  
  7. 'This is the function that is entered from the call in the polling thread
  8. 'All it does is some logic and conversion then calls ValueChanged event
  9. Public Function SetCurrentValue(ByVal inValue As Double, _
  10.                                     Optional ByVal RaiseEvents As Boolean = True, _
  11.                                     Optional ByVal inNewValue As Double = 0, _
  12.                                     Optional ByVal DisplayNormal As String = "") As Boolean
  13.  
  14. 'This is the value changed event. I have different ones, but this is one example that controls a percent bar
  15. Private Sub _myPoint_ValueChanged(ByVal NewValue As Double, ByVal DisplayNormal As String, ByVal UnitText As String) Handles _myPoint.ValueChanged
  16.     CurrentValue = NewValue
  17.         hpbProgresBar.SetValue(Int(NewValue))
  18.         SetTextPercent(NewValue)
  19. End Sub
  20.  
  21. 'This is how I change the gui in the form using a delegate
  22. Delegate Sub SetTextPercentDelegate(ByVal inValue As Double)
  23. Private Sub SetTextPercent(ByVal inValue As Double)
  24.  
  25.         If lblPercent.InvokeRequired Then
  26.             Dim d As New SetTextPercentDelegate(AddressOf SetTextPercent)
  27.             Me.Invoke(d, New Object() {inValue})
  28.         Else
  29.             lblPercent.Text = Int(inValue) & " %"
  30.         End If
  31. End Sub
Add Comment
Please, Sign In to add comment