Solved

Programming with MSComm - new to VB

Posted on 1997-06-10
4
412 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now