Option Explicit
Dim VariableX As Single
Private Sub Form_Load()
With MSComm1
.CommPort = 1 ' Se usara el puerto Com1
.Settings = "19200,N,8,1" ' Velocidad de Tx 19200 baud, no paridad, 8 bits de datos, y 1 bit de stop
.InputMode = comInputModeBinary
.InputLen = 0 ' El control MSComm leera todo el contenido del búfer de recepción
.RThreshold = 1
.RTSEnable = True
.SThreshold = 1
.PortOpen = True
End With
Grafica.DrawWidth = 3
End Sub
Private Sub CmdEnviar_Click()
MSComm1.InBufferCount = 0 'reseta el buffer de recepcion
MSComm1.Output = TxtEnviar.Text & Chr$(13)
Do While MSComm1.OutBufferCount > 0
Loop
End Sub
Private Sub CmdSal_Click()
MSComm1.PortOpen = False
End
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
Dim VariableY As String
VariableY = MSComm1.Input
If IsNumeric(VariableY) Then 'Si el valor recibido es un valor numerico entonces...
VariableX = VariableX + 50 'Autoincrementar posicion X
Grafica.PSet (VariableX, Grafica.Height - CSng(VariableY)), vbRed 'Dibujar punto en la grafica e invertir eje Y
End If
End Select
End Sub