Print a line in DOS COnsole through VB6

Hello All
I am Akthar and I am new to this form, I have a question in VB6 application,.
I ave created an application in VB that can run in both GUI and dos mode. in dos mode it will run like a batch process. Now I am stuck in returning a value ina dos mode.
What I mean is if my application returns an error I need to capture it and print in to the active DOS console.
Can some one please help me with this situation./
Thanks
Salutation.
Akthar
AKthar_mailmeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vinnyd79Commented:
"If a Visual Basic application is started from a console application, the operating system automatically detaches it from the console, preventing the Visual Basic application from interacting with it."

The above is from this link:

http://support.microsoft.com/default.aspx?scid=kb;en-us;171654

0
vinnyd79Commented:
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
It IS possible to make your VB6 app echo back to the same DOS console from which it was run.

I have successfully used the technique described here:
http://www.charteris.com/Publications/SendFile.asp?Type=WhitePapers&Filename=UsingTheFileSystemObjectsInVisualBasic.pdf

I created a new project and added a reference to the Microsoft Scripting Runtime.  Then I added a Module with the following code:

    Sub Main()
        Dim fso As New FileSystemObject
        fso.GetStandardStream(StdOut).Write ("Hello World")
    End Sub

From the Project Properties, I set the startup object to be Sub Main and then removed Form1 from the project.  I compiled the application as VBConsole.exe in the following folder:

    C:\Program Files\Microsoft Visual Studio\VC98\Bin

Then I copied this file into the Bin folder as well:

    C:\Program Files\Microsoft Visual Studio\VB98\MSPDB60.DLL

Next I used the EditBin utility as described in the PDF document and ran VBConsole.  "Hello World" did echo back successfully to the DOS console from which my app was run.  Here is the text from my Console window showing EditBin being used and then VBConsole.Exe being run:

C:\PROGRA~1\MICROS~6\VC98\BIN>editbin /subsystem:console vbconsole.exe
Microsoft (R) COFF Binary File Editor Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.



C:\PROGRA~1\MICROS~6\VC98\BIN>vbconsole
Hello World
C:\PROGRA~1\MICROS~6\VC98\BIN>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonMiddle School Assistant TeacherCommented:
From my Feedback:

Thanks a lot for your help, I did went with this approch but I got an error in this, it says RunTime Error '2147024890(80070006) Method '~' od Object '~' failed
what shall I do, at his point since I am new to Vb and I still have a hude distance to cover.
Thanks a lot again.
Akthar

Make sure you have a reference to the Microsoft Scripting Runtime added to your project by selecting Project --> References from the menu.

I am running VB6 (SP6) in WinXP Pro with all updates.

~IM
0
vinnyd79Commented:
Dan, I think this one should go to Idle Mind.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.