Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print to the output stream

Posted on 2001-06-11
2
Medium Priority
?
137 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
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
jrspano earned 339 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
Suggested Courses

782 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