Solved

Print to the output stream

Posted on 2001-06-11
2
128 Views
Last Modified: 2010-05-02
I am developing a small, non-visual VB application which needs to send different messages to the DOS prompt.
I could not find a VB function which does it (something like 'printf' in C).
Also, if there is no such function in VB, does anyone know an API function instead of ?

Regards
0
Comment
Question by:marper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
jrspano earned 113 total points
ID: 6177303
from planet source code

'**************************************
' Name: Send Keys/commands to DOS (the e
'     asy method)
' Description:Sending keystrokes to dos
'     is not as easy as the "Sendkeys" functio
'     n, which is designed specifically for wi
'     ndows based programs. So this program is
'     designed to add on to that function and
'     send keystrokes to dos. The program can
'     actually send any size text to the comma
'     nd prompt, from one keystroke to complet
'     e commands. It allows the programmer to
'     completely control dos applications.
' By: Philip Leitch
'
' Inputs:you will need to start a dos se
'     ssion, either before or during your appl
'     ication. If you are starting a dos sessi
'     on during the session you sould use the
'     following code:
x = shell("command", 0)
this will create a dos session, With windows handle of "x", which will be hidden from the program user.
Once created To End the session the standard "exit" can be sent to the command line.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/xq/ASP/txtCode
'     Id.3593/lngWId.1/qx/vb/scripts/ShowCode.
'     htm'for details.'**************************************



Public Sub Dos_Send(CommandWindowName as string, SendToDos as string)
    clipboard.Clear
    'clear the clipboard (obvious)
    Clipboard.SetText SendToDos ' + Chr$(13)
    'send the relevent key/command to the cl
    '     ipboard
    'note that the Chr$(13) is requried to i
    '     f the "SendToDos" text is a dos command
    '     or 'requires the pressing of the Enter/R
    '     eturn key after the relevent string has
    '     been 'sent.
    AppActivate CommandWindowName
    'CommandWindowName is MS-DOS Prompt, or
    '     whatever appears in your task bar.
    'See the AppActivate for more info.
    'A good alternative is to use the handle
    '     (hwind) of the dos window
    SendKeys "% ep", 1
    'this sends the clipboard to dos
    'Now wasn't that simple?
End Sub
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6177339
here is a sample also that does more on the console

http://www.freevbcode.com/ShowCode.Asp?ID=1265
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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 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…

738 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