Function NewPLCFXENTE(ByVal PortNum As String) As Object
Try
Dim PLCFX As New ActProgTypeLib.ActProgType
Dim PLCType As Integer = 520
Dim PLCUnitType As Integer = 74
Dim PLCUnitNumber As Integer = 0
Dim PLCPrgType As Integer = 5
Dim PLCHostAddress As String = ""
Dim PLCTimeOut = 500
With PLCFX
.ActCpuType = PLCType
.ActUnitType = PLCUnitType
.ActUnitNumber = PLCUnitNumber
.ActProtocolType = PLCPrgType
' .ActHostAddress = "192.168.1." & PortNum
.ActHostAddress = PortNum
.ActTimeOut = PLCTimeOut
End With
Return PLCFX
Catch ex As Exception
MsgBox(ex.Message)
MLog.LogErrWrite(ex.ToString)
End Try
End Function
PLC0 = PLCM.NewPLCFXENTE(IPAddress(0))
PLCConErr(0) = PLC0.Open