Source code and the explanation is as follows:
'get all the OPC server: OPC_GetAllServers
'parameters:
'RemoteMachineName: remote computer name,] [optional parameters, if the query on the local computer OPC server this parameter is ignored;
'if the query on the remote computer of OPC server, enter the IP address of the remote computer (such as "192.168.1.100") or the computer name
'return values: save all the set of OPC server name (String collection)
The Public Function OPC_GetAllServers (Optional RemoteMachineName As String) As a Collection
Set OPC_ServerCollection=New Collection 'create OPC_ServerCollection Collection objects
Dim As Integer I
On Error GoTo ErrorHandler
The Set OPC_ServerObj=New OPCServer 'create OPC server object
Dim AllServers As the Variant
AllServers=OPC_ServerObj. GetOPCServers (RemoteMachineName) 'access to all the name of the OPC server (returns a String array)
For I=LBound (AllServers) To UBound (AllServers)
OPC_ServerCollection. Add AllServers (I) 'the OPC server name added to the collection OPC_ServerCollection
Next I
Set OPC_ServerObj release OPC server object=Nothing '
Set OPC_GetAllServers=OPC_ServerCollection 'return OPC_ServerCollection collection
The Exit Function
'error handling
ErrorHandler:
MsgBox "get all the OPC server failed!" , vbOKOnly, "error" 'errors
Set OPC_GetAllServers=OPC_ServerCollection 'return OPC_ServerCollection collection
End the Function
Consult everybody the teacher
'RemoteMachineName: remote computer name,] [optional parameters, if the query on the local computer OPC server this parameter is ignored;
'if the query on the remote computer of OPC server, enter the IP address of the remote computer
This sentence how to modify, thank you