Solved

vb help

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

18 Experts available now in Live!

Get 1:1 Help Now