Results 1 to 3 of 3

Thread: Transmitting data through a serial port

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    127
    This is a simple question, I've tried to get it to work, but failed, so now I'm asking the guru's

    What code is needed to be able to pass information through a serial port, and what command actually passes the information or string?

    Any information would be helpful.

    Thanx.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    From the MS Help pages on MSComm Control

    Slightly modified, and not at all complete to handle input/output, but it is a start for you..

    Code:
    ' on a form with a MSComm constol, textbox and command button...
    ' I commented out the stuff relating to talking to a modem 
    ' don't forget to specify the type of serial handshaking as well.  Default is none.
    Option Explicit
    
    Private Sub Command1_Click()
     
      MSComm1.Output = Text1.Text
    End Sub
    
    Private Sub Form_Load()
       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 = "ATV1Q0" & Chr$(13) ' Ensure that
       ' the modem responds with "OK".
       ' Wait for data to come back to the serial port.
    '   Do
    '    DoEvents
    '    Buffer$ = Buffer$ & MSComm1.Input
    '   Loop Until InStr(Buffer$, "OK" & vbCrLf)
       ' Read the "OK" response data in the serial port.
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
       MSComm1.PortOpen = False
       ' Close the serial port.
    
    End Sub
    
    Private Sub MSComm1_OnComm()
      ' do something in here whenever the control detects a comms event
    End Sub
    Regards
    Paul Lewis

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    127
    Thanx, I'll work on it.

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