How To Access COM Port using VB

Hi there!!
I'm new to Programmers Heaven.
Can Some one help me to get the code for accessing Serial Ports (i.e.) COM ports using a VB Program
Regards
Amit Patole

Comments

  • : Hi there!!
    : I'm new to Programmers Heaven.
    : Can Some one help me to get the code for accessing Serial Ports (i.e.) COM ports using a VB Program
    : Regards
    : Amit Patole
    :
    Add a MSCOMM control to the form. It looks like a telephone on your componets selections. If you don't see it, right click in the componets bar, select componets, then scroll through the componets and check the "Microsoft Comm Control". Help gives some examples of how to use it.

  • : : Hi there!!
    : : I'm new to Programmers Heaven.
    : : Can Some one help me to get the code for accessing Serial Ports (i.e.) COM ports using a VB Program
    : : Regards
    : : Amit Patole
    : :
    : Add a MSCOMM control to the form. It looks like a telephone on your componets selections. If you don't see it, right click in the componets bar, select componets, then scroll through the componets and check the "Microsoft Comm Control". Help gives some examples of how to use it.
    :
    :
    Thanks For Your Hlp
    Can u pls send me some example as i am doing a Project in which I have to access a device with a 9 pin serial connector
    Regards.
    Amit Patole
  • : : : Hi there!!
    : : : I'm new to Programmers Heaven.
    : : : Can Some one help me to get the code for accessing Serial Ports (i.e.) COM ports using a VB Program
    : : : Regards
    : : : Amit Patole
    : : :
    : : Add a MSCOMM control to the form. It looks like a telephone on your componets selections. If you don't see it, right click in the componets bar, select componets, then scroll through the componets and check the "Microsoft Comm Control". Help gives some examples of how to use it.
    : :
    : :
    : Thanks For Your Hlp
    : Can u pls send me some example as i am doing a Project in which I have to access a device with a 9 pin serial connector
    : Regards.
    : Amit Patole
    :


    From the Microsoft help
    MSComm Control Example
    The following simple example shows basic serial communications using a modem:

    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 = "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.
    ' Close the serial port.
    MSComm1.PortOpen = False
    End Sub

    Note The MSComm control can use polling or an event-driven method to retrieve data from the port. This simple example uses the polling method. For an example of the event-driven method, see help for the OnComm event.

  • : : : : Hi there!!
    : : : : I'm new to Programmers Heaven.
    : : : : Can Some one help me to get the code for accessing Serial Ports (i.e.) COM ports using a VB Program
    : : : : Regards
    : : : : Amit Patole
    : : : :
    : : : Add a MSCOMM control to the form. It looks like a telephone on your componets selections. If you don't see it, right click in the componets bar, select componets, then scroll through the componets and check the "Microsoft Comm Control". Help gives some examples of how to use it.
    : : :
    : : :
    : : Thanks For Your Hlp
    : : Can u pls send me some example as i am doing a Project in which I have to access a device with a 9 pin serial connector
    : : Regards.
    : : Amit Patole
    : :
    :
    :
    : From the Microsoft help
    : MSComm Control Example
    : The following simple example shows basic serial communications using a modem:
    :
    : 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 = "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.
    : ' Close the serial port.
    : MSComm1.PortOpen = False
    : End Sub
    :
    : Note The MSComm control can use polling or an event-driven method to retrieve data from the port. This simple example uses the polling method. For an example of the event-driven method, see help for the OnComm event.
    :
    :
    Hi Buddy,
    Thanks a lot for your quick responce and help
    Regards,
    Amit Patole
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories