Results 1 to 4 of 4

Thread: how to read from the serial port

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    2

    Post

    how can i read from the serial port?
    does it have an interrupt?

  2. #2
    New Member
    Join Date
    May 1999
    Location
    Kariong, NSW, Australia
    Posts
    2

    Post

    Use the MSComm control that is shipped with VB. The VB help has reasonable examples of how to define, open and read from a serial port. However, if you need to read in Binary data, don't use the MS example. Respond back to this forum and I will post a code snippet for serial binary data reception.

    Adrian

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    2

    Post

    Hi:

    first of all thanks...
    I don't have the help files so I don't have
    any example...
    I need to read bits, 8 per transmission
    if it's possible.
    If you can give me the code or command
    it will be a great help.

    thanks
    pan

  4. #4
    New Member
    Join Date
    May 1999
    Location
    Kariong, NSW, Australia
    Posts
    2

    Post

    Life's going to be rather hard without the Help files.

    Below is a very basic example from the VB Help. I don't know whether I'm supposed to paste this Help snippet or not, apologies if this is the wrong thing to do.

    Private Sub Form_Load ()
    ' Buffer to hold input string
    Dim Instring As String
    ' Use COM1.
    MSComm1.CommPort = 1
    ' 9600 baud, no parity, 8 data, and 1 stop bit.
    MSComm1.Settings = "9600,N,8,1"
    ' Tell the control to read entire buffer when Input
    ' is used.
    MSComm1.InputLen = 0
    ' Open the port.
    MSComm1.PortOpen = True
    ' Send the attention command to the modem.
    MSComm1.Output = "AT" + Chr$(13)
    ' Wait for data to come back to the serial port.

    Do
    DoEvents
    Loop Until MSComm1.InBufferCount >= 2
    ' Read the "OK" response data in the serial port.
    Instring = MSComm1.Input
    ' Close the serial port.
    MSComm1.PortOpen = False
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width