i wrote this code to send a byte the the COM1 when an arrow is pressed on the keyboard
Option Explicit
Private Sub Command1_Click()
MSComm1.PortOpen = False
End
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "2400,N,8,1"
MSComm1.DTREnable = True
MSComm1.PortOpen = True
Dim oApp As Object
Dim oDoc As Object
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.documents.open("C:\Test.doc")
oApp.Visible = True
Set oDoc = Nothing
Set oDoc = Nothing
Me.KeyPreview = True
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 37
MSComm1.Output = "11110010"
Text1.Text = 11110010
Case 38
MSComm1.Output = "11110001"
Text1.Text = 11110001
Text2.Text = MSComm1.OutBufferCount
Case 39
MSComm1.Output = "11111000"
Text1.Text = 11111000
Text2.Text = MSComm1.OutBufferCount
Case 40
MSComm1.Output = "11110100"
Text1.Text = 11110100
Text2.Text = MSComm1.OutBufferCount
End Select
End Sub
i tested the COM out buffer by using
Text2.Text = MSComm1.OutBufferCount
but it returned nottin which means the serial port isnt getting the byte!
can anyone help with this?
