Hi, I have the following code:
It works fine, but I want to run this code in:
and in:
This is probably a simple question, but how do I do this, and where and how should I do the declarations (especially the 'WithEvents' declaration is causing problems)?
Thank you very much!
Code:
Option Explicit
Option Base 1
Private MyOPCServer As OPCServer
Private WithEvents MyOPCgroup1 As OPCGroup
Private WithEvents MyOPCgroup2 As OPCGroup
Private MyOPCItems1, MyOPCItems2 As OPCItem
Private Sub CommandButton1_Click() 'connect
Set MyOPCServer = New OPCServer
Call MyOPCServer.connect("S7200.OPCServer")
Set MyOPCgroup1 = MyOPCServer.OPCGroups.Add("Gruppe1")
Set MyOPCgroup2 = MyOPCServer.OPCGroups.Add("Gruppe2")
MyOPCgroup1.IsSubscribed = True
MyOPCgroup1.UpdateRate = 0
MyOPCgroup2.IsSubscribed = True
MyOPCgroup2.UpdateRate = 0
Set MyOPCItems1 = MyOPCgroup1.OPCItems.AddItem("MicroWin.PLC1.Plaatnummer", 1)
Set MyOPCItems2 = MyOPCgroup2.OPCItems.AddItem("MicroWin.PLC1.M1,0", 2)
End Sub
Code:
Private Sub CommandButton1_Click()
End Sub
Code:
Private Sub Workbook_Open()
End Sub
Thank you very much!