rs232.rar
hỳ hục cả nửa tháng nay mà e vẫn ko xog được cái phần này. các bác giúp e tìm chỗ sai vs ah.
E xin cám ơn.
hỳ hục cả nửa tháng nay mà e vẫn ko xog được cái phần này. các bác giúp e tìm chỗ sai vs ah.
E xin cám ơn.
Dim BytesReceived() As Byte Private Sub Form_Load() With MSComm1 .CommPort = 2 'chose COM2 .Settings = "9600,N,8,1" 'baud 9600bps, none parity, 8 bit data, 1 bit stop .InBufferSize = 1024 .InputLen = 0 .RThreshold = 1 .SThreshold = 0 .OutBufferSize = 512 .InputMode = comInputModeBinary '.InputMode = comInputModeText .PortOpen = True End With End Sub Private Sub MSComm1_OnComm() 'Read and Store the 1 byte data BytesReceived() = MSComm1.Input End Sub Private Sub cmd_back_Click() Text1.Text = Hex$(BytesReceived(0)) End Sub Private Sub cmd_exit_Click() MSComm1.PortOpen = False End End Sub Private Sub cmd_led1_Click(Index As Integer) MSComm1.Output = Chr$(1) End Sub Private Sub cmd_led2_Click(Index As Integer) MSComm1.Output = Chr$(2) End Sub Private Sub cmd_led3_Click(Index As Integer) MSComm1.Output = Chr$(4) End Sub Private Sub cmd_led4_Click(Index As Integer) MSComm1.Output = Chr$(8) End Sub
Dim BytesReceived() As Byte Private Sub Form_Load() With MSComm1 .CommPort = 2 'chose COM2 .Settings = "9600,N,8,1" 'baud 9600bps, none parity, 8 bit data, 1 bit stop .InBufferSize = 1024 .InputLen = 0 .RThreshold = 1 .SThreshold = 0 .OutBufferSize = 512 .InputMode = comInputModeBinary '.InputMode = comInputModeText .PortOpen = True End With End Sub Private Sub MSComm1_OnComm() 'Read and Store the 1 byte data BytesReceived() = MSComm1.Input End Sub Private Sub cmd_back_Click() Text1.Text = Hex$(BytesReceived(0)) End Sub Private Sub cmd_exit_Click() MSComm1.PortOpen = False End End Sub Private Sub cmd_led1_Click(Index As Integer) MSComm1.Output = Chr$(1) End Sub Private Sub cmd_led2_Click(Index As Integer) MSComm1.Output = Chr$(2) End Sub Private Sub cmd_led3_Click(Index As Integer) MSComm1.Output = Chr$(4) End Sub Private Sub cmd_led4_Click(Index As Integer) MSComm1.Output = Chr$(8) End Sub
Dim BytesReceived() As Byte Private Sub Form_Load() With MSComm1 .CommPort = 2 'chose COM2 .Settings = "9600,N,8,1" 'baud 9600bps, none parity, 8 bit data, 1 bit stop .InBufferSize = 1024 .InputLen = 0 .RThreshold = 1 .SThreshold = 0 .OutBufferSize = 512 .InputMode = comInputModeBinary '.InputMode = comInputModeText .PortOpen = True End With End Sub Private Sub MSComm1_OnComm() 'Read and Store the 1 byte data BytesReceived() = MSComm1.Input End Sub Private Sub cmd_back_Click() Text1.Text = Hex$(BytesReceived(0)) End Sub Private Sub cmd_exit_Click() MSComm1.PortOpen = False End End Sub Private Sub cmd_led1_Click(Index As Integer) MSComm1.Output = Chr$(1) End Sub Private Sub cmd_led2_Click(Index As Integer) MSComm1.Output = Chr$(2) End Sub Private Sub cmd_led3_Click(Index As Integer) MSComm1.Output = Chr$(4) End Sub Private Sub cmd_led4_Click(Index As Integer) MSComm1.Output = Chr$(8) End Sub
Comment