| |

ActiveX-ProgrammierungRe: Aufrufen von ActiveX exe | |  | Autor: DerWolf | Datum: 26.04.03 19:15 |
| Hallo,
Das ganze ActiveX-Exe ist in einer Class. Es existiert nur ein kleines Form (nicht angezeigt) mit einem Timer-Control und einem RS232-Controll.
Ansonsten nachfolgender code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Type PumpStringDef
high As String
low As String
default As String
End Type
Type PumpDef
Busy As Boolean
On As Boolean
ID As Integer
SendString As String
LastSync As Long
MaxSyncTime As Long
Port As Object
TimeOut As Single
Buffer As String
Error As Long
ErrDescription As String
Pressure As Long
End Type
Public Event Error(Value As Long)
Public Event Pressure(Pressure As Long)
Public Event Fault(DiffTime As Long)
....
Private WithEvents ePumpTimer As Timer
Private Sub Class_Initialize()
Set Pump.Port = PumpForm.RS232Pump
Set ePumpTimer = PumpForm.PumpTimer
Pump.MaxSyncTime = 12000
SyncString = "0310ED;"
StartString.high = "061180006009;"
StartString.low = "061180002049;"
...
End Sub
Public Function PumpActivate(Port As Integer) As Boolean
Pump.Port.Settings = "9600,n,8,1"
Pump.Port.CommPort = Port
Pump.Port.Handshaking = 0
Pump.Port.PortOpen = True
PumpActivate = True
End Function
Public Function PumpDeActivate() As Boolean
Pump.Port.PortOpen = False
PumpDeActivate = True
End Function
Public Function PumpAction(Action As String, Optional TimeOut As Long = 1000) _
As Boolean
Pump.TimeOut = TimeOut
Select Case Action
Case "PumpOn"
PumpAction = SendPump("Start")
Case "PumpOff"
PumpAction = SendPump("Stop")
...
End Select
End Function
Private Sub ePumpTimer_Timer()
Dim Flag As Boolean
Flag = SendPump("Sync")
End Sub
Private Function SendPump(Action As String) As Boolean
Dim StartSendPump As Long
If Pump.Busy Then
SendPump = False
Exit Function
End If
Pump.Busy = True
If ((GetTickCount - Pump.LastSync) > Pump.MaxSyncTime) _
And (Action <> "Start") Then RaiseEvent Fault(GetTickCount - _
Pump.LastSync - Pump.MaxSyncTime)
Select Case Action
Case "Sync"
Case "Start"
mSync = True
Pump.On = True
StartString.default = StartString.low
StopString.default = StopString.low
Pump.SendString = StartString.default
Case "Stop"
mSync = False
Pump.On = False
Pump.SendString = StopString.default
StartString.default = StartString.low
StopString.default = StopString.low
Case "High"
StartString.default = StartString.high
StopString.default = StopString.high
Pump.SendString = StartString.default
Case "Low"
StartString.default = StartString.low
StopString.default = StopString.low
Pump.SendString = StartString.default
Case "Pressure"
Case Else
SendPump = False
Pump.Busy = False
Exit Function
End Select
Pump.Buffer = ""
Pump.Port.Output = "!Q" & Pump.SendString
While InStr(1, Pump.Buffer, ".") = 0 And Pump.Error = 0
If Pump.Port.InBufferCount Then
Pump.Port.InputLen = 0
Pump.Buffer = Pump.Buffer & Pump.Port.Input
End If
Pump.Error = IIf((GetTickCount - StartSendPump) > Pump.TimeOut, 101, 0)
DoEvents
Wend
If (Pump.Error <> 0) Then GoTo PumpErrorHandling
Pump.Pressure = Val("&H" + Mid$(Pump.Buffer, 7, 2)) * 2
Pump.Buffer = ""
StartSendPump = GetTickCount
Pump.Port.Output = "!Q" & SyncString
While InStr(1, Pump.Buffer, ".") = 0 And Pump.Error = 0
If Pump.Port.InBufferCount Then
Pump.Port.InputLen = 0
Pump.Buffer = Pump.Buffer & Pump.Port.Input
End If
Pump.Error = IIf((GetTickCount - StartSendPump) > Pump.TimeOut, 201, 0)
DoEvents
Wend
If (Pump.Error <> 0) Then GoTo PumpErrorHandling
Pump.LastSync = GetTickCount
If Action = "Pressure" Then RaiseEvent Pressure(Pump.Pressure)
Pump.Busy = False
ePumpTimer.Enabled = mSync
SendPump = True
Exit Function
PumpErrorHandling:
SendPump = False
Pump.Busy = False
RaiseEvent Error(Pump.Error)
ePumpTimer.Enabled = mSync
Pump.Error = 0
End Function
Private Sub Class_Terminate()
If Not (ePumpTimer Is Nothing) Then
ePumpTimer.Enabled = False
End If
Set ePumpTimer = Nothing
Set Pump.Port = Nothing
Unload PumpForm
End Sub musste ein paar Code - Zeilen löschen. |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
sevGraph (VB/VBA) 
Grafische Auswertungen
Präsentieren Sie Ihre Daten mit wenig Aufwand in grafischer Form. sevGraph unterstützt hierbei Balken-, Linien- und Stapel-Diagramme (Stacked Bars), sowie 2D- und 3D-Tortendiagramme und arbeitet vollständig datenbankunabhängig! Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) Access-Tools Vol.1 
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
Copyright ©2000-2025 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|