I’m new to programing so I’m hoping you can help me. Not sure how to formulate the right question so I didn’t find any StackOverflow answers.
When I step through this code and come to OpcServObj.Connect OpcServerStrg it doesn't connect. I get no errors, nothing appears to happen. Cursor jumps to the left margin and does nothing. Only when I resume stepping through the routine it starts the function over again. It should continue and exit the for loop where I plan to test the state of the connection again.
Reference Library: OPC DA Automation Wrapper 2.02
Sub Main()
ConnectOPC
End Sub
Private Function ConnectOPC() As Boolean
Dim OpcServObj As OPCAutomation.OPCServer
Dim OpcGroupObj As OPCAutomation.OPCGroup
Dim OPCServerlist As Variant
Dim OpcServerStrg As String
Set OpcServObj = New OPCAutomation.OPCServer
OPCServerlist = OpcServObj.GetOPCServers
If OpcServObj.ServerState <> True Then
For i = 1 To UBound(OPCServerlist)
OpcServerStrg = OPCServerlist(i)
If OpcServerStrg = "ICONICS.IconicsOPCUAServer.V5" Then
OpcServObj.Connect OpcServerStrg
Exit For
End If
Next i
End If
End Function
Thanks