Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, new to VB and I'm trying to use sample codes to see how the form runs once compiled. Each time I try anything though the form outputs blank... what am I doing wrong?

Sample code I used:

Module HelloWorld
Sub Main()
System.Console.WriteLine("Hello world!")
End Sub
End Module

What I have tried:

I've tried unloading the project and editing VB project itself; tried multiple sample codes, tried multiple basic formats...
Posted
Updated 29-Dec-17 20:09pm
Comments
Dave Kreskowiak 29-Dec-17 21:50pm    
What kind of app did you create? WPF, Windows Forms, Console, ASP.NET, ... what?

1 solution

Forms apps don't use the console: they don't have one. They are very different from the Console apps you seem to be used to!

You can output to the console from within a forms-based app, but you need to run it in the debugger to see the output - it will appear in the Output pane, mixed in with threading (and suchlike) messages from the framework (and it's a better idea to use Debug.WriteLine instead of Console.WriteLine as they are automatically removed from production code).

Otherwise, to output messages in a Forms app, you need to add a Label or a TextBox to your app, and set it's Text property:
VB
MyLabel.Text = "Hello World!"
Do that in a suitable Event handler (perhaps the Form.Shown event) And you will be able to read it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900