Solved

Something wrong with receiving and displaying hex format data by using MsComm

Posted on 2003-10-31
4
597 Views
Last Modified: 2010-05-01
The following program is basic communication between PC and MCU by using MsComm. I send a "hex 35" to MCU, then MCU will return 22 bytes hex one time . I have already tested my MCU(8031) programe by LookRS232(serial com debuger). It's OK.
The question is the following program has sent "hex 35" successfully, but it can not display all 22 bytes in the Text1.Text . Only the first byte display in that.  How can I do?  Thank you in advance!


Private Sub Command2_Click()
   ' Buffer to hold input string
   Dim Instring As String
   Dim Buffer1 As String
   ' Use COM1.
   MSComm1.CommPort = 1
   ' 600 baud, no parity, 8 data, and 1 stop bit.
   MSComm1.Settings = "600,N,8,1"
   ' Tell the control to read entire buffer when Input
   ' is used.
   MSComm1.InBufferCount = 0 ' Clear Input Buffer
   MSComm1.InputLen = 0
   MSComm1.InBufferSize = 1024
   ' Open the port.
   MSComm1.PortOpen = True
   ' Send the attention command to the modem.
   MSComm1.Output = Chr$(&H35) ' Ensure that
   ' the modem responds with "OK".
   ' Wait for data to come back to the serial port.

   Do While MSComm1.InBufferCount <> 0
       DoEvents
        Buffer1 = Buffer1 + MSComm1.Input
         Text1.Text = Text1.Text & (Hex(Asc(Buffer1)))
   Loop


   ' Read the "OK" response data in the serial port.
   ' Close the serial port.
   MSComm1.PortOpen = False
   

End Sub
0
Comment
Question by:VB_newer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 125 total points
ID: 9667849
try this:
'mscomm1.inputlen = 0
loop until mscomm1.inbuffercount >= 22
text1.text = val(mscomm1.input)

thanks,
~ fantasy ~




0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 1 hour left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question