• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

Programming with MSComm - new to VB

Hello

I am working with Visual Basic for the first time.
 I want the following to happen: 2 computers connected to
 1 via two cables to the two com ports. When I send a simple
messages from these two the "server" must display these
 messages on one screen, even if sent at the same time.
 I am currently browsing through the MSComm functions -
can a null modem cable be used without all the handshaking.

Thank You

Hennie Snyman
0
hen
Asked:
hen
  • 2
1 Solution
 
y96andhaCommented:
It is best to use handshaking, but it can be used without it if the server is fast enough and you do not use too high speeds. If you wish to use handshaking, you only have to enable it, the rest is handled automatically.
0
 
henAuthor Commented:
I wanted more detail, like how to actually write a program, as I have no previous experience in VB
0
 
ChrisLewisCommented:
I don't have a way to test this out, but try something liek this:

two Text boxes, 1 command button (SEND) , 1 mscomm

+----------+
Option Explicit

Private Sub Command1_Click()
  MSComm1.Output = Text2.Text
  Text2 = ""
End Sub

Private Sub Form_Load()
' Use COM1.
  MSComm1.CommPort = 1
  ' 9600 baud, no parity, 8 data, and 1 stop bit.
  MSComm1.Settings = "9600,N,8,1"
  MSComm1.RThreshold = 1
  MSComm1.PortOpen = True
End Sub

Private Sub Form_unLoad()
  MSComm1.PortOpen = False
End Sub

Private Sub MSComm1_OnComm()
  Select Case MSComm1.CommEvent
    ' Handle each event or error by placing
    ' code below each case statement
    ' Errors
    Case comEventBreak  ' A Break was received.
    Case comEventCDTO ' CD (RLSD) Timeout.
    Case comEventCTSTO  ' CTS Timeout.
    Case comEventDSRTO  ' DSR Timeout.
    Case comEventFrame  ' Framing Error
    Case comEventOverrun  ' Data Lost.
    Case comEventRxOver ' Receive buffer overflow.
    Case comEventRxParity ' Parity Error.
    Case comEventTxFull ' Transmit buffer full.
    Case comEventDCB  ' Unexpected error retrieving DCB]

  ' Events
    Case comEvCD  ' Change in the CD line.
    Case comEvCTS ' Change in the CTS line.
    Case comEvDSR ' Change in the DSR line.
    Case comEvRing  ' Change in the Ring Indicator.
    Case comEvReceive ' Received RThreshold # of  chars.
      Text1 = Text1 & MSComm1.Input
    Case comEvSend  ' There are SThreshold number of characters in the transmit buffer.
    Case comEvEOF ' An EOF charater was found in the input stream
  End Select

End Sub


This is taken from the examples and some work that I did in the past.

You will have to have two machines connected via a null modem.  I've hard coded com1 9600,n,8,1, which should do.

For your specific instance, you will want to have two sending
programs and one recieving program.  The recieving program will probably need two MSComms, one for each port.

Good luck
Chris
0
 
henAuthor Commented:
Thank you very much, but I am not certain the two messages sent at the same
time from the 2 computers will be handled by the "server" - will the one not interrupt
the other? Thanks again
Hennie
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now