Solved

Print to the output stream

Posted on 2001-06-11
2
123 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now