Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Serial Port..

Serial Port..

Scheduled Pinned Locked Moved Visual Basic
comtutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Subjugate
    wrote on last edited by
    #1

    I currently have a project regarding com port and i am new to serial port function. Is there anyone with example regarding this area??

    A L 2 Replies Last reply
    0
    • S Subjugate

      I currently have a project regarding com port and i am new to serial port function. Is there anyone with example regarding this area??

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Subjugate wrote:

      Is there anyone with example regarding this area

      Yep. Google.

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • S Subjugate

        I currently have a project regarding com port and i am new to serial port function. Is there anyone with example regarding this area??

        L Offline
        L Offline
        Levisvv
        wrote on last edited by
        #3

        Start a project in VB, and add the component: MScomm Control. Copy the icon of a telephone onto a form, then write some code to enable the COM port like:

        MSComm1.Settings = "9600,n,8,1"
        MSComm1.ParityReplace = ""
        On Error GoTo COMerr
        MSComm1.PortOpen = True
        Exit sub
        COMerr:
        msgbox "A COM error occured:" & err.number & vbcrlf & err.description
        End Sub

        To send data out the COM port use: MSComm1.Output = "This text string will go out the COM port." To trap received data on the serial port, you must add this to the MScomm1.OnComm event:

        dim TCin as string
        if MSComm1.CommEvent = MSCOMM_EV_RECEIVE then
        TCin = MSComm1.Input
        msgbox Received: " & TCin
        end if

        You should also include these in a declarations file:

        '--- MSComm event constants
        Global Const MSCOMM_EV_SEND = 1
        Global Const MSCOMM_EV_RECEIVE = 2
        Global Const MSCOMM_EV_CTS = 3
        Global Const MSCOMM_EV_DSR = 4
        Global Const MSCOMM_EV_CD = 5
        Global Const MSCOMM_EV_RING = 6
        Global Const MSCOMM_EV_EOF = 7

        '--- MSComm error code constants
        Global Const MSCOMM_ER_BREAK = 1001
        Global Const MSCOMM_ER_CTSTO = 1002
        Global Const MSCOMM_ER_DSRTO = 1003
        Global Const MSCOMM_ER_FRAME = 1004
        Global Const MSCOMM_ER_OVERRUN = 1006
        Global Const MSCOMM_ER_CDTO = 1007
        Global Const MSCOMM_ER_RXOVER = 1008
        Global Const MSCOMM_ER_RXPARITY = 1009
        Global Const MSCOMM_ER_TXFULL = 1010

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups