473,473 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB.NET: Console.Writeline() to DOS prompt when Forms app invoked from DOS

1 New Member
This is my first post on this site, so I don't know the rules. Please correct me if this gets to the wrong folks...etc.

PROBLEM: Many of the apps that I am writing need to be able to run 2 ways: They might be invoked from the command-line with parameters so that they do not show UI, but accomplish some task; OR they might be double-clicked, in which case they show a UI (so that the User can configure settings for the app...etc.).

To this end, I create the application as a Forms Application, but have a module that contains a

Public Sub Main(ByVal args() As String)

...procedure as the 'Startup object'.

If the app is double-clicked, there are no 'args', so I just ShowDialog() on the Main Form.

If the app is run from the command-line with args, then I don't ShowDialog() on the MainForm, and just do the work.

OK so far.

QUESTION: In the case where the User runs the application from the command line, I would like to write output to the DOS window (for ex: if they enter the incorrect args, then I want to display correct usage). But Console.Writeline() doesn't put output to the DOS window that the app is being run in?

How can I acheive this?

Am I wrong in doing things the way I am doing them with regards to my strategy of using a Forms Application but starting it with a Sub Main? Should I have created a Console application that somehow displays Forms?

Any help greatly appreciated!
Nov 8 '07 #1
1 5949
Plater
7,872 Recognized Expert Expert
if your program type is set to windows application (go to the properties of the project) then for some reason the "console" never runs correctly. Set it to a console application and you should see your output in the commandline that the program was invoked in. (Yes, you will still be able to do the showdialog() even in a console application....unless they changed something without me noticing)
Nov 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the...
16
by: Simon | last post by:
I am a programming student and have recently missed two weeks of school due to a serious injury in a car accident. I am completing all of my assignments (via Labs) but have come across the...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
4
by: GTi | last post by:
I have a program that will act as an Remoting server AND client. This program can be loaded on one macine or it can be loaded on several machines. But it will only be one master program...
5
by: Peter Proost | last post by:
Hi I got this piece of c# code which runs ok but now I translated it to vb.net (see bottom of post for both pieces) and it keeps erroring out at pi.SetValue(testForm, newValue, x) with this error:...
4
by: eduardorp1 | last post by:
I have a GUI application that needs to be invoked from the command line as well. It should work both as a GUI and as a console application. When I invoke it from the command line, it reads all...
3
by: Geoff McElhanon | last post by:
I have been struggling with a security issue that occurs under .NET 2.0, but does not occur under .NET 1.1. Essentially I am trying to open up a performance counter on a remote server and monitor...
0
by: kolalakitty | last post by:
Hopefully someone here can help me/point me in the right direction. I've found tons of references towards making relations, creating rows, saving said rows, using datagrids, databinding objects,...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.