I am adding the maco code, so I hope someone can find a error…
Option Explicit
Private Declare Function Version Lib “k8055d.dll” () As Long
Private Declare Function SearchDevices Lib “k8055.d.dll” () As Long
Private Declare Function SetCurrentDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Function OpenDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Sub CloseDevice Lib “k8055d.dll” ()
Private Declare Function ReadAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib “k8055d.dll” (Data1 As Long, Data2 As Long)
Private Declare Sub OutputAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub OutputAllAnalog Lib “k8055d.dll” (ByVal Data1 As Long, ByVal Data2 As Long)
Private Declare Sub ClearAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib “k8055d.dll” ()
Private Declare Sub ClearAllAnalog Lib “k8055d.dll” ()
Private Declare Sub SetAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub WriteAllDigital Lib “k8055d.dll” (ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib “k8055d.dll” ()
Private Declare Sub SetDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib “k8055d.dll” ()
Private Declare Function ReadDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib “k8055d.dll” () As Long
Private Declare Function ReadCounter Lib “k8055d.dll” (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib “k8055d.dll” (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib “k8055d.dll” (ByVal CounterNr As Long, ByVal DebounceTime As Long)
Dim i As Long
Dim j As Long
Dim k As Long
Dim h As Long
Dim s As Long
Private Sub CommandButton1_Click() ’ herstellen der Verbindung und Zählerstand holen
OpenDevice (0) 'verbinden mit Gerät 0 (Jumper SK5,SK6 - 0,1,2,3)
h = OpenDevice(0)
If h = 0 Then
i = ReadCounter(1)
j = ReadCounter(2)
k = i + j
s = k * 2
ActiveSheet.Cells(6, 17) = " "
ActiveSheet.Cells(9, 17) = "MP1- " & i
ActiveSheet.Cells(10, 17) = "MP2- " & j
ActiveSheet.Cells(12, 17) = “Doppelbeutel”
ActiveSheet.Cells(13, 17) = "Summe- " & k
ActiveSheet.Cells(15, 17) = “Einzelbeutel”
ActiveSheet.Cells(16, 17) = "Summe- " & s
ClearAllDigital
CloseDevice
Else
ActiveSheet.Cells(6, 17) = “Zähler nicht gefunden”
End If
End Sub
Private Sub CommandButton3_Click()
OpenDevice (0)
ResetCounter (1)
ResetCounter (2)
h = OpenDevice(0)
If h = 0 Then
i = 0
j = 0
k = 0
s = 0
ActiveSheet.Cells(6, 17) = " "
ActiveSheet.Cells(9, 17) = "MP1- " & i
ActiveSheet.Cells(10, 17) = "MP2- " & j
ActiveSheet.Cells(12, 17) = “Doppelbeutel”
ActiveSheet.Cells(13, 17) = "Summe- " & k
ActiveSheet.Cells(15, 17) = “Einzelbeutel”
ActiveSheet.Cells(16, 17) = "Summe- " & s
ClearAllDigital
CloseDevice
Else
ActiveSheet.Cells(6, 17) = “Zähler nicht gefunden”
End If
End Sub