VB Example

[Home] [SI_SCOPE] [SI_COMM] [COMM-DRV/LIB] [COMM-LOGGER] [I/O Boards]

 

The following code is from an example program included with SI_COMM. The program is a simple break out monitor that displays the state of the modem signals RI, CTS, DCD, and DSR. Shown below is the compiled program running under Windows 95.

vbexample.gif (1338 bytes)

The diodes are just VB shape controls colored Green when the signal is high or Black when the signal is low. 


'************************************************************************
'*  This source file is provided as a supplement to the SI_COMM package.
'*
'*  SI_COMM.OCX Copyright (C) 1998 Software Innovations Inc
'*  All rights reserved.
'*
'************************************************************************
Option Explicit
'************************************************************************
'************************************************************************
Private Sub Form_Load()

' Open the port...
    SI_COMM1.PortOpen = True

' Initialize the diodes to the state of the Modem Signals....

   If SI_COMM1.CTS = True Then shpCTS.FillColor = vbGreen
   If SI_COMM1.DSR = True Then shpDSR.FillColor = vbGreen
   If SI_COMM1.DCD = True Then shpDCD.FillColor = vbGreen
   If SI_COMM1.RI = True Then shpRI.FillColor = vbGreen

' Tell the control to generate a CommEvent whenever on of the Modem
' Signals change...

   SI_COMM1.DeltaDCD = True
   SI_COMM1.DeltaCTS = True
   SI_COMM1.DeltaRI = True
   SI_COMM1.DeltaDSR = True

End Sub

'************************************************************************
' In the CommEvent handler decode the nature of the event by examining the
' the value in iEventCode. Set the color of the correct diode to Green
' if the signal is high, Black if the signal went low.
'************************************************************************
Private Sub SI_COMM1_CommEvent(ByVal iEventCode As Integer)

   Select Case iEventCode

   Case DCDEvt

      If SI_COMM1.DCD = True Then
         shpDCD.FillColor = vbGreen
      Else
         shpDCD.FillColor = vbBlack
      End If

   Case CTSEvt

      If SI_COMM1.CTS = True Then
         shpCTS.FillColor = vbGreen
      Else
         shpCTS.FillColor = vbBlack
         End If

   Case DSREvt

      If SI_COMM1.DSR = True Then
         shpDSR.FillColor = vbGreen
      Else
         shpDSR.FillColor = vbBlack
      End If

   Case RIEvt

      If SI_COMM1.RI = True
         Then shpRI.FillColor = vbGreen
      Else
         shpRI.FillColor = vbBlack
      End If

End Select

End Sub

 

Send mail to webmaster@sinnovations.com with questions or comments about this web site.
Copyright © 1999-2003 Software Innovations Inc.
This page last updated on 04/23/2005