📄 mainform.frm
字号:
Index = 0
Left = 1440
Locked = -1 'True
TabIndex = 5
TabStop = 0 'False
Top = 840
Width = 4755
End
Begin VB.Label Label4
Caption = "Data Item 1"
Height = 255
Left = 240
TabIndex = 24
Top = 240
Width = 1575
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Caption = "Write Value:"
Height = 255
Left = 240
TabIndex = 23
Top = 1590
Width = 975
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
Caption = "Read Value:"
Height = 255
Left = 240
TabIndex = 22
Top = 1230
Width = 975
End
Begin VB.Label Label7
Caption = "Data Item 2"
Height = 255
Left = 240
TabIndex = 21
Top = 2040
Width = 1815
End
Begin VB.Label Label8
Alignment = 1 'Right Justify
Caption = "Data Change:"
Height = 255
Left = 240
TabIndex = 20
Top = 870
Width = 1095
End
Begin VB.Label Label9
Alignment = 2 'Center
Caption = "Callback Count"
Height = 495
Left = 6360
TabIndex = 19
Top = 240
Width = 615
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Caption = "Data Change:"
Height = 255
Left = 240
TabIndex = 18
Top = 2670
Width = 1095
End
Begin VB.Label Label10
Alignment = 1 'Right Justify
Caption = "Read Value:"
Height = 255
Left = 240
TabIndex = 17
Top = 3030
Width = 975
End
Begin VB.Label Label11
Alignment = 1 'Right Justify
Caption = "Write Value:"
Height = 255
Left = 240
TabIndex = 16
Top = 3390
Width = 975
End
End
Begin VB.TextBox tbSourceCode
BackColor = &H80000013&
Height = 3015
Left = 240
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 6000
Width = 9015
End
Begin VB.Frame Frame1
Caption = "Source Code of Activity"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3375
Left = 120
TabIndex = 2
Top = 5760
Width = 9255
End
Begin VB.CommandButton cmdExit
BackColor = &H00C0FFC0&
Caption = "Exit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3255
Left = 9480
Style = 1 'Graphical
TabIndex = 1
Top = 5880
Width = 1695
End
Begin VB.Label Label16
Alignment = 2 'Center
BackColor = &H00FFFFFF&
BackStyle = 0 'Transparent
Caption = "www.saeautom.sk"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 238
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800000&
Height = 495
Left = 120
TabIndex = 47
Top = 9240
Width = 11055
End
End
Attribute VB_Name = "MainForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'***********************************************************************************************
'** *
'** Copyright: SAE-Automation,s.r.o.Nova Dubnica, Slovakia, *
'** *
'***********************************************************************************************
'** *
'** Project: OPC Client SNMP Project name: OPC Client SNMP *
'** *
'***********************************************************************************************
'** @doc EXTERNAL *
'** @module MainForm.frm | *
'** *
'** *
'***********************************************************************************************
'** @info *
'** Version : 1.0<nl> *
'** Compiler : Microsoft Visual Basic.NET <nl> *
'** Author : Mi, SAE-Automation,s.r.o.<nl> *
'***********************************************************************************************
'** @history *
'** Mi 1.0.0 02.08.2005 Initial version<nl> *
'***********************************************************************************************/
Option Explicit
Option Base 1
Private MyOPCServer As OPCServer ' OPCServer Object
Private MyGroups As OPCGroups ' OPCGroups Collection Object
Private WithEvents MyGroup As OPCGroup ' OPCGroup Object
Attribute MyGroup.VB_VarHelpID = -1
Private MyItems As OPCItems ' OPCItems Collection Object
Private MyItemServerHandles() As Long ' Server Handles for Items
Dim MyTID As Long ' Transaction ID for asynchronous calls
'************************************************************************************************
'** @Sub cmdConnect_Click | function for connect to OPC server *
'** *
'** This function create a connection to OPC Server<nl> *
'** *
'************************************************************************************************
Private Sub cmdConnect_Click()
On Error GoTo ErrorHandler ' Code that may or may not contain errors
Set MyOPCServer = New OPCServer ' Create OPCServer Object
Call MyOPCServer.Connect(cmbListOpcServer.Text) ' Connect from OPC Server
' Set Button Enable
Me.cmdConnect.Enabled = False ' Button conect disabled
Me.cmdDisconnect.Enabled = True ' Button disconect enabled
Me.cmdAddGroup.Enabled = True ' Button add group enabled
Me.cmbListOpcServer.Enabled = False ' Commbobox select server disabled
'Multi line text for editbox
Me.tbSourceCode.Text = "Private Sub cmdConnect_Click()" & ChrW(13) & ChrW(10) & ChrW(9) & ChrW(9) & ChrW(13) & ChrW(10) & " MyOPCServer = New OPCAutomation.OPCServer " & _
"' Create OPCServer Object" & ChrW(13) & ChrW(10) & " Call MyOPCServer.Connect(txtServer.Text) ' Conn" & _
"ect from OPC Server" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "End Sub"
'
Exit Sub
ErrorHandler: ' Code that handles errors
MsgBox Err.Description + Chr(13) + "Connecting to OPC Server", vbCritical, "ERROR"
End Sub
'************************************************************************************************
'** @Sub cmdDisconnect_Click | function for Disconnect to OPC server *
'** *
'** This function create a disconnection to OPC Server<nl> *
'** *
'************************************************************************************************
Private Sub cmdDisconnect_Click()
On Error GoTo ErrorHandler ' Code that may or may not contain errors
MyOPCServer.Disconnect ' Disconnect from OPC Server
Set MyOPCServer = Nothing ' Delete OPCServer Object
' Set Button Enable
Me.cmdConnect.Enabled = True ' Button conect enabled
Me.cmdDisconnect.Enabled = False ' Button disconect disabled
Me.cmdAddGroup.Enabled = False ' Button add group disabled
Me.cmbListOpcServer.Enabled = True ' Commbobox select server disabled
' Multi line text for editbox of info code
Me.tbSourceCode.Text = "Private Sub cmdDisconnect_Click()" & ChrW(13) & ChrW(10) & ChrW(9) & ChrW(9) & ChrW(13) & ChrW(10) & " MyOPCServer.Disconnect ' Disconnect fro" & _
"m OPC Server" & ChrW(13) & ChrW(10) & " Set MyOPCServer = Nothing ' Delete OPCServer Object" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "End Sub"
'
Exit Sub
ErrorHandler: ' Code that handles errors
MsgBox Err.Description + Chr(13) + "Disconnecting from OPC Server", vbCritical, "ERROR"
End Sub
'************************************************************************************************
'** @Sub cmdAddGroup_Click | function for get OPCGroups Collection Object from MyOPCServer *
'** *
'** This function add a new Group to the Groups Collection<nl> *
'** *
'************************************************************************************************
Private Sub cmdAddGroup_Click()
On Error GoTo ErrorHandler ' Code that may or may not contain errors
Set MyGroups = MyOPCServer.OPCGroups ' Get OPCGroups Collection Object from MyOPCServer
' Set Default Properties for Group Collection
' These Properties are used to set the Properies for new Groups
MyGroups.DefaultGroupIsActive = 500 ' Set Default Group Update Rate to 500 ms
Set MyGroup = MyGroups.Add(txtGroup.Text) ' Add a new Group to the Group Collection
' Set Group Properties
MyGroup.IsSubscribed = True ' Enable Callbacks
If CheckGroupActive.Value = 1 Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -