Console.write() not functioning with application type "windows application"

JohnathonH

New member
Joined
Jun 9, 2006
Messages
1
Programming Experience
3-5
Currently my code looks like this

VB.NET:
Module main[INDENT]Dim LOGFILE As String = ".\Logfile.log"
Dim objLogfileOutput As New System.IO.StreamWriter(LOGFILE, True)
[/INDENT][INDENT] Sub main()[INDENT]sendToLog("Write this to debug, the log file, and console")
[/INDENT]End Sub
Function sendToLog(ByVal textToWrite As String) As String[INDENT]Debug.WriteLine(textToWrite)
objLogfileOutput.WriteLine(textToWrite)
Console.Write(textToWrite)
Return ""
[/INDENT]End Function
[/INDENT]End Module
The problem lies that Console.write(textToWrite) does not function properly and I dont understand what I am doing incorrectly.

I do not want my application to auto launch a dos box, but i do want it to redirect the output if it was launched from a dos box.

Any insight would be helpful.

Thanks
Johnathon H.
 
To answer at least your one question about why console.writeline, this is because you have started your application as a Windows Application instead of Console Application.

I see that you are seemingly wanting to output to the console only if started from the console, but even if execute from the console your Windows Application will naturally display its GUI form, unless you supress it.

Not sure exactly what you are trying to achieve here, perhaps more detail could lend a better answer for you, but for now at least instead of Console.Write you would be looking to write your output to a multiline textbox or similar, OR, convert your application to a Console Application instead.a
 
Back
Top