System.Console.writeline not working
Hi There,
Today I have started learning Vb.net and when I am writing the below given program it does not give me anything on console screen. Could anyone please help me with this.
Imports System
Module Module1
Sub Main()
System.Console.WriteLine(True)
System.Console.WriteLine("hello")
End Sub
End Module
Re: System.Console.writeline not working
Did you check out the documentation on the Console in MSDN?
http://msdn2.microsoft.com/en-us/lib...m.console.aspx
Re: System.Console.writeline not working
I checked the msdn but it still does not work..
Re: System.Console.writeline not working
I've only glanced at the Console application a couple of times before but it's my understanding that as soon as it hits the end sub bit it exits the program.
The example on the first page of that link i sent you - did you try it??
The line in the example: Dim name As String = Console.ReadLine()
forces the console to await user input. I think you have to implement something similar. The examples I've seen before usually put a loop in until the user input equals some value before exiting.
Re: System.Console.writeline not working
Quote:
Originally Posted by Harry123
Hi There,
Today I have started learning Vb.net and when I am writing the below given program it does not give me anything on console screen. Could anyone please help me with this.
Imports System
Module Module1
Sub Main()
System.Console.WriteLine(True)
System.Console.WriteLine("hello")
End Sub
End Module
Hi,
You could try something like this:
Code:
Imports System
Module Module1
Sub Main()
Dim ps as string = "True"
Dim pb as string = "hello"
System.Console.WriteLine(ps)
System.Console.WriteLine("pb")
End Sub
End Module
Hope it helps,
sparrow1
Re: System.Console.writeline not working
This is also not working on console I get only this.
C:\il>vbc a.vb
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
a.vb is my file name...
Re: System.Console.writeline not working
You need to put a Console.Readline() whenever you want it to pause.
Example:
Code:
'The below line will make the console show: The First Line!
Console.Writeline("The First Line!")
'The below line will make the console wait until you want to continue
Console.Readline()
Re: System.Console.writeline not working
You do not need console.readline to stop the window closing. Simply hit ctrl + F5 to run the app instead of the green arrow and the window will not close. Also Make sure you are actually running a console project and not a windows form one.
http://img168.imageshack.us/img168/7299/captureqc8.jpg
Re: System.Console.writeline not working
I didn't say it would 'stop the window closing' only that is would make the console display the message and then wait.
Re: System.Console.writeline not working
Quote:
Originally Posted by Harry123
This is also not working on console I get only this.
C:\il>vbc a.vb
Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
a.vb is my file name...
Well, this is the problem... that's not how you run a console app.... you COMPILE it first... and run the .EXE that is created....
All you did was "run" the vb file, which it treated as a script, and since there were no calls to the Main sub, nothing happened.
-tg
Re: System.Console.writeline not working