Solved

vb help

Posted on 1998-06-26
1
135 Views
Last Modified: 2010-05-03
This seems like a really easy question, but could somebody help me.  I am trying to communicate with a serial comm port through visual basic and I don't know the commands to use to open the port or to send a simple string command to an external module,
                 Thanks,  
 
0
Comment
Question by:maddux
1 Comment
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1464433
You should use the MSComm control.
The following simple example shows basic serial communications using a modem:
Private Sub Form_Load ()
  ' Buffer to hold input string
  Dim Instring As String
  ' Use COM1.
  MSComm1.CommPort = 1
  ' 9600 baud, no parity, 8 data, and 1 stop bit.
  MSComm1.Settings = "9600,N,8,1"
  ' Tell the control to read entire buffer when Input
  ' is used.
  MSComm1.InputLen = 0
  ' Open the port.
  MSComm1.PortOpen = True
  ' Send the attention command to the modem.
  MSComm1.Output = "AT" + Chr$(13)
  ' Wait for data to come back to the serial port.

  Do
    DoEvents
  Loop Until MSComm1.InBufferCount >= 2
  ' Read the "OK" response data in the serial port.
  Instring = MSComm1.Input
  ' Close the serial port.
  MSComm1.PortOpen = False
End Sub


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

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

932 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

8 Experts available now in Live!

Get 1:1 Help Now