Note: This is using VisiWin.Net so it has more functions than VB.NET just in case anyone didn't quite understand what was happening.
For my work I have to declare a variable "StateItem2" and "DigitalItem2" in the "Initialization" section and later in the program have a button that when clicked it changed a property binding so that the fill colour changes (from gray to lime) when a valve is open / running. The code is shown below.
cmdTest is a button
WCP01_AV001_1 - is a triangle shape
If I run this then I get the error message "error BC30451: Name 'StateItem2' is not declared."
Also I can get the code working partially if I have sub under the declarations in the "Initialization" (and if my system is running) without the button click (just the info inside it). I need the button for future testing purposes.
I know there isn't any syntax errors I just need to know about using the Initialization declarations in the button click sub :)
Thanks for any help that can be given
**FIXED**
For my work I have to declare a variable "StateItem2" and "DigitalItem2" in the "Initialization" section and later in the program have a button that when clicked it changed a property binding so that the fill colour changes (from gray to lime) when a valve is open / running. The code is shown below.
Code:
Public Class Wort_Copper_Mimic
Inherits VisiWinNET.Forms.SmartForm
#Region "Initialization"
''' <summary>
''' This method is called, when the Form is initialized.
''' </summary>
Public Sub New()
' This call is required by the Windows Form Designer.
' Do not remove this line.
InitializeComponent()
' Add any initialization here:
Dim StateItem2 As VisiWinNET.DataAccess.StateItem = New VisiWinNET.DataAccess.StateItem
Dim DigitalItem2 As VisiWinNET.DataAccess.DigitalItem = New VisiWinNET.DataAccess.DigitalItem
End Sub
#End Region
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click
CType(Me.WCP01_AV001_1, System.ComponentModel.ISupportInitialize).BeginInit()
StateItem2.Mode = VisiWinNET.DataAccess.ItemMode.Value
StateItem2.Name = "Ch1.Machine04.Application.HMI_LAMPS.WCP01_LP<[13]>"
StateItem2.Range = CType(2, Long)
Me.WCP01_AV001_1.PropertyBindings.AddRange(New VisiWinNET.Forms.IPropertyBinding() {New VisiWinNET.Forms.ColorBinding("FillColor", StateItem2, DigitalItem2, New VisiWinNET.Forms.ColorCollection(New System.Drawing.Color() {System.Drawing.Color.Gray, System.Drawing.Color.Lime}))})
CType(Me.WCP01_AV001_1, System.ComponentModel.ISupportInitialize).EndInit()
Me.Refresh
End Sub
WCP01_AV001_1 - is a triangle shape
If I run this then I get the error message "error BC30451: Name 'StateItem2' is not declared."
Also I can get the code working partially if I have sub under the declarations in the "Initialization" (and if my system is running) without the button click (just the info inside it). I need the button for future testing purposes.
I know there isn't any syntax errors I just need to know about using the Initialization declarations in the button click sub :)
Thanks for any help that can be given
**FIXED**