?
Solved

Programming with MSComm - new to VB

Posted on 1997-06-10
4
Medium Priority
?
439 Views
Last Modified: 2008-03-06
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
Comment
Question by:hen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:y96andha
ID: 1427047
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
 

Author Comment

by:hen
ID: 1427048
I wanted more detail, like how to actually write a program, as I have no previous experience in VB
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 800 total points
ID: 1427049
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
 

Author Comment

by:hen
ID: 1427050
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question