Solved

Programming with MSComm - new to VB

Posted on 1997-06-10
4
433 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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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