Solved

vb help

Posted on 1998-06-26
1
136 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 70
Copy a row 12 61
Notepad++ how to remove delimiter : from beggning of the line? 3 104
How to incorporate an error traping routing to existing code in VB6 11 40
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

770 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