Solved

VB & COM Ports...

Posted on 1998-06-28
1
191 Views
Last Modified: 2010-05-03
Well... it's quite simple... the question:

DOS:    echo babykins > com1
VB4.0:  ????

I need to tell VB to echo a command to the comport (The command is only a text string:  babykins)
0
Comment
Question by:coolcole
1 Comment
 
LVL 1

Accepted Solution

by:
khaledc earned 50 total points
ID: 1464505
Have a you had a look at  MSComm Control, it deals with serial communication.
If you are after semding a string over com1 then, first you should include the MSComm Control (from the Components list of VB), then you could write something like this :
' 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

Hope that could help
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

773 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