home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
bp_3_94
/
vbwin
/
comm
/
vbcomm3.frm
< prev
next >
Wrap
Text File
|
1994-05-03
|
4KB
|
128 lines
VERSION 2.00
Begin Form Form1
BackColor = &H00C0C0C0&
Caption = "BP 3/94 ** Comm-Tester 3 (mit OnComm) **"
ClientHeight = 4110
ClientLeft = 915
ClientTop = 1515
ClientWidth = 6945
Height = 4515
Left = 855
LinkTopic = "Form1"
ScaleHeight = 4110
ScaleWidth = 6945
Top = 1170
Width = 7065
Begin TextBox Text1
Height = 3570
Left = 105
MultiLine = -1 'True
ScrollBars = 3 'Beide
TabIndex = 0
Top = 90
Width = 6705
End
Begin MSComm Comm1
Interval = 55
Left = 6375
RTSEnable = -1 'True
Top = 3540
End
Begin Label lblStatus
BackColor = &H00C0C0C0&
BorderStyle = 1 'nicht Σnderbar, einfach
Height = 360
Left = 90
TabIndex = 1
Top = 3735
Width = 6810
End
End
DefInt A-Z
Sub Comm1_OnComm ()
Static Zeile$
lblStatus.Caption = "" 'Statuszeile l÷schen (optional)
If Comm1.CommEvent > 1000 Then 'Rote Statusmeldung fⁿr Fehler ...
lblStatus.ForeColor = &HFF&
Else
lblStatus.ForeColor = &H0& '... sonst schwarzer Text
End If
Select Case Comm1.CommEvent
'Ereignisse
Case MSCOMM_EV_CD
lblStatus.Caption = " PegelΣnderung der CD-Leitung"
Case MSCOMM_EV_CTS
lblStatus.Caption = " PegelΣnderung der CTS-Leitung"
Case MSCOMM_EV_DSR
lblStatus.Caption = " PegelΣnderung der DSR-Leitung "
Case MSCOMM_EV_RING
lblStatus.Caption = " RING (LΣuten)"
'EMPFANG
Case MSCOMM_EV_RECEIVE 'RThreshold Anzahl Zeichen empfangen
Form1.Caption = "Im Empfangspuffer: " + Str$(Comm1.InBufferCount)
Ein$ = Comm1.Input
If Len(Ein$) > 0 Then
If Asc(Ein$) = 13 Then
lblStatus.Caption = "CR empfangen"
Ein$ = Ein$ + Chr$(13) + Chr$(10) 'Neue Zeile in Text1 erzwingen (optional)
End If
End If
Text1.Text = Text1.Text + Ein$
Text1.SelStart = Len(Text1.Text)
Text1.SelText = ""
Case MSCOMM_EV_SEND
lblStatus.Caption = " In SThreshold angegebene Zeichenanzahl unterschritten"
Case MSCOMM_EV_EOF
lblStatus.Caption = "Dateiende-Zeichen (EOF) empfangen"
'Fehlercodes (> 1000)
Case MSCOMM_ER_BREAK
lblStatus.Caption = " Break-Signal empfangen"
'hier ggf. Code zur Break-Behandlung vorsehen...
Case MSCOMM_ER_CDTO
lblStatus.Caption = " Carrier Detect Timeout"
Case MSCOMM_ER_CTSTO
lblStatus.Caption = " Clear To Send Timeout"
Case MSCOMM_ER_DSRTO
lblStatus.Caption = " Data Set Ready Timeout"
Case MSCOMM_ER_FRAME
lblStatus.Caption = " Fehlerhafte Rahmen-Bits"
Case MSCOMM_ER_OVERRUN
lblStatus.Caption = " Overrun (Zeichen 'verschluckt')"
Case MSCOMM_ER_RXOVER
lblStatus.Caption = " Empfangspuffer-▄berlauf"
Case MSCOMM_ER_RXPARITY
lblStatus.Caption = " ParitΣtsfehler (Empfang)"
Case MSCOMM_ER_TXFULL
lblStatus.Caption = " Sendepuffer voll"
End Select
End Sub
Sub Form_Load ()
Comm1.CommPort = 2 'COM2 verwenden (VOR dem ╓ffnen angeben!)
Comm1.Settings = "1200,N,8,1" '1200 Baud, keine ParitΣt, 8 Datenbits, 1 Stopbit
Comm1.InputLen = 1 'Mit Input je 1 Zeichen lesen
Comm1.OutBufferSize = 512 'Sendepuffer
Comm1.InBufferSize = 1024 'Empfangspuffer (testweise =1 setzen, um
'▄berlauffehler zu provozieren)
Comm1.RThreshold = 1 'Fⁿllstand bis zum OnComm-Ereignis
'(hier: Ereignis jedem Zeichen)
Comm1.PortOpen = True 'COM-Port ÷ffnen
End Sub
Sub Form_Unload (Cancel As Integer)
Comm1.PortOpen = False 'COM-Port schlie▀en
End Sub
Sub Text1_KeyPress (KeyAnsi As Integer)
Comm1.Output = Chr$(KeyAnsi)
End Sub