Solved

Console application in VB6

Posted on 2004-10-01
8
299 Views
Last Modified: 2010-05-02
How do I make a console application using Sub Main() ?

I'd need something like:

Public Sub Main()
dim o as myObject
set o=createobject("myobjeclib.object")
...
o.method
PrintToConsole o.property
..
set o=Nothing
End Sub
0
Comment
Question by:gregajesih
8 Comments
 
LVL 10

Accepted Solution

by:
Clif earned 100 total points
ID: 12199985
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12200370
There are plenty of examples in VB where you create a new console and then write to it.

If you what you are looking for is a VB app that can write to the DOS window from where it was run then you are out of luck.

~IM
0
 

Author Comment

by:gregajesih
ID: 12200686
Well, almost. Thanks. But I did not mention that I'd appreciate that application is run within the same cmd window.
So a session stating which program was run and print command$ would be something like:

c:\>console.exe "some_text"
Console.exe program v1.0
some_text

c:\>
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12200709
It can't be done in VB6.

~IM
0
 
LVL 10

Expert Comment

by:Clif
ID: 12200744
I beg to differ.

The code example from the site I posted indeed writes to the console (ie DOS screen)
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 50 total points
ID: 12200781
You are right Clif.

The code you provided does indeed write to a console...but it is a console created by the application.

What gregajesih is looking for is a way for the app to write the same DOS window from which it was called.  If you open up a DOS prompt and run the program by typing in its name, then the app should be able to output to that same window.

I have yet to see an example of this done in VB6.

~IM
0
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 100 total points
ID: 12203930
If you need a true console application why not use Visual Studio to create one in C?
All you need do is write the functionality in VB and have it translated here or in the C topic area.

I agree that a true console app is not supported in VB.  It would be easier to learn a few lines in C than hacking through a VB console interface.
0
 
LVL 12

Expert Comment

by:jkaios
ID: 12216425
VB.Net is got a nice one!
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link a textbox in excel to a cell with more than 255 characters. 5 89
Problem to skip loop 6 57
Copy a row 12 62
Added a column screws up code 5 57
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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