Solved

Programming with MSComm - new to VB

Posted on 1997-06-10
4
415 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now