-Em muốn gửi dữ liệu xuống VDK từ VB6 dạng binary nhưng send thì toàn bị lỗi cả,có ai bít giúp em với :
Private Sub Command2_Click()
On Error GoTo connectfalse
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Exit Sub
connectfalse:
MsgBox "Loi Connect"
End Sub
Private Sub Command1_Click()
On Error GoTo sendfalse
Dim BytesToSend(0) As Byte
Dim Buffer As Variant
BytesToSend(0) = &H4A
Buffer = BytesToSend(0)
Text3.Text = Buffer
MSComm1.Output = Buffer
Exit Sub
sendfalse:
MsgBox "Loi Send"
End Sub
Private Sub Form_Load()
With MSComm1
.Settings = "9600,N,8,1"
.RThreshold = 2
.SThreshold = 0
.InBufferSize = 1024
.OutBufferSize = 1024
.InputMode = comInputModeBinary
.ParityReplace = ""
.CommPort = 1
End With
End Sub
Private Sub MSComm1_OnComm()
Dim BytesReceived(0) As Byte
Dim Buffer As Variant
If MSComm1.CommEvent = comEvReceive Then
Buffer = MSComm1.Input
BytesReceived(0) = Buffer
Text2.Text = BytesReceived(0)
End If
End Sub
Private Sub Command2_Click()
On Error GoTo connectfalse
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Exit Sub
connectfalse:
MsgBox "Loi Connect"
End Sub
Private Sub Command1_Click()
On Error GoTo sendfalse
Dim BytesToSend(0) As Byte
Dim Buffer As Variant
BytesToSend(0) = &H4A
Buffer = BytesToSend(0)
Text3.Text = Buffer
MSComm1.Output = Buffer
Exit Sub
sendfalse:
MsgBox "Loi Send"
End Sub
Private Sub Form_Load()
With MSComm1
.Settings = "9600,N,8,1"
.RThreshold = 2
.SThreshold = 0
.InBufferSize = 1024
.OutBufferSize = 1024
.InputMode = comInputModeBinary
.ParityReplace = ""
.CommPort = 1
End With
End Sub
Private Sub MSComm1_OnComm()
Dim BytesReceived(0) As Byte
Dim Buffer As Variant
If MSComm1.CommEvent = comEvReceive Then
Buffer = MSComm1.Input
BytesReceived(0) = Buffer
Text2.Text = BytesReceived(0)
End If
End Sub
Comment