Hallo Patrick,
nicht so schnell aufgeben. Schau Dir doch noch mal das Excel Beispiel an, dort wird doch auch mit Visual Basic, wenn auch VBA gearbeitet.
Versuche doch zunächst dich mal mit der easy zu verbinden, z.B.
retval = Open_ComPort(com_port_nr:=2, baudrate:=19200)
Ist retval =0 ist alles in Ordnung, ansonsten kannst du den Fehlercode in der PDF Doku der LIB nachlesen.
Als zweiten Schritt versuchst du die Verbindung wieder zu schliessen:
retval = Close_ComPort
Auch hier gilt retval=0 ist alles in Ordnung.
Nun taste dich langsam heran, z.B. easy Stoppen und Starten:
retval = Stop_Program(net_id:=0, Errorcode:=0)
retval = Start_Program(net_id:=0, Errorcode:=0)
Wenn du soweit gekommen bist ist der Rest nur noch Formsache.
Hier noch das Einbinden der kompletten DLL:
Option Explicit
Private Declare Function Open_ComPort Lib "EASY_COM.DLL" _
(ByVal com_port_nr As Byte, _
ByVal baudrate As Long) As Long
Private Declare Function Close_ComPort Lib "EASY_COM.DLL" () As Long
Private Declare Function GetCurrent_Baudrate Lib "EASY_COM.DLL" _
(ByRef baudrate As Long) As Long
Private Declare Function Open_EthernetPort Lib "EASY_COM.DLL" _
(ByVal szIpAddress As String, _
ByVal IpPort As Long, _
ByVal baudrate As Long, _
ByVal no_baudrate_scan As Boolean) As Long
Private Declare Function Close_EthernetPort Lib "EASY_COM.DLL" () As Long
Private Declare Function Stop_Program Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, ByRef Errorcode As Byte) As Long
Private Declare Function Start_Program Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, ByRef Errorcode As Byte) As Long
Private Declare Function Read_Clock Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByRef year As Byte, _
ByRef month As Byte, _
ByRef day As Byte, _
ByRef hour As Byte, _
ByRef min As Byte) As Long
Private Declare Function Write_Clock Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByRef year As Byte, _
ByRef month As Byte, _
ByRef day As Byte, _
ByRef hour As Byte, _
ByRef min As Byte) As Long
Private Declare Function Read_Object_Value Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal object As Byte, _
ByVal index As Integer, _
ByRef data As Byte) As Long
Private Declare Function Write_Object_Value Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal object As Byte, _
ByVal index As Integer, _
ByVal length As Byte, _
ByRef data As Byte) As Long
Private Declare Function Read_Channel_YearTimeSwitch Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal index As Byte, _
ByVal channel As Byte, _
ByRef on_year As Byte, _
ByRef on_month As Byte, _
ByRef on_day As Byte, _
ByRef off_year As Byte, _
ByRef off_month As Byte, _
ByRef off_day As Byte) As Long
Private Declare Function Write_Channel_YearTimeSwitch Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal index As Byte, _
ByVal channel As Byte, _
ByRef on_year As Byte, _
ByRef on_month As Byte, _
ByRef on_day As Byte, _
ByRef off_year As Byte, _
ByRef off_month As Byte, _
ByRef off_day As Byte) As Long
Private Declare Function Read_Channel_7DayTimeSwitch Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal index As Byte, _
ByVal channel As Byte, _
ByRef DY1 As Byte, _
ByRef DY2 As Byte, _
ByRef on_hour As Byte, _
ByRef on_minute As Byte, _
ByRef off_hour As Byte, _
ByRef off_minute As Byte) As Long
Private Declare Function Write_Channel_7DayTimeSwitch Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal index As Byte, _
ByVal channel As Byte, _
ByRef DY1 As Byte, _
ByRef DY2 As Byte, _
ByRef on_hour As Byte, _
ByRef on_minute As Byte, _
ByRef off_hour As Byte, _
ByRef off_minute As Byte) As Long
Private Declare Function Unlock_Device Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByVal szPassword As String, _
ByRef Errorcode As Byte) As Long
Private Declare Function Lock_Device Lib "EASY_COM.DLL" _
(ByVal net_id As Byte, _
ByRef Errorcode As Byte) As Long
Viele Grüße
Paul