Solved

Print to the output stream

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 75
Error when passing an argument to a vb6 that contains  '/' 7 39
Help me. 3 60
Export Data to Different .csv Files 26 114
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

789 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