Hallo, please, I have RX and TX pins at serial cable at my computer connect. In hyper terminal I try, that is all OK, I send and recive data.
In visual basic I send BYTES with code which I send down OK, but when I use
dat = READBYTE
Text2.Text = Str$(dat)
I not view data which I send...I cant read bytes value...please, help me, I have visual basic 5
Private Sub Command1_Click()
'MSComm1.Output = "12345"
'MSComm1.Output = "Test rs232"
'MSComm1.Output = Chr(32 + 3) + Chr(32 + (1532 \ 224)) + Chr((32 + 1532 Mod 224)) & vbCr
MSComm1.Output = (xconvert(3, 1532))
End Sub
Private Sub Form_Load()
Form1.Caption = "App1"
With MSComm1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "2400,n,8,1"
.SThreshold = 1
.PortOpen = True
End With
Command1.Caption = "&Print rs232"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
Private Function xconvert(ByVal register As Integer, ByVal xval As Integer) As String
register = 3
xval = 1532
xconvert = Chr(32 + register) + Chr(32 + (xval \ 224)) + Chr((32 + xval Mod 224)) & vbCr
End Function
Private Sub MSComm1_OnComm()
Dim sData As String
If MSComm1.CommEvent = comEvReceive Then
' sdata = MSComm1.Input ' Get data (2 bytes)
' lHighByte = Asc(Mid$(sData, 1, 1)) ' get 1st byte
' lLowByte = Asc(Mid$(sData, 2, 1)) ' Get 2nd byte
' Combine bytes into a word
'lWord = (lHighByte * &H100) Or lLowByte
' Convert value to a string and display
' Label1.Caption = CStr(sData)
' Label1.Caption = CStr(sdata)
End If
'sData = MSComm1.Input
'Label1.Caption = CStr(sData)
'Label1.Caption.Byte = Chr(sData)
'If MSComm1.CommEvent > -1 Then Text1.Text = CStr(sData)
dat = READBYTE
Text1.Text = Text1.Text + dat + " "
Text2.Text = Str$(dat)
End Sub