jjoselon
jjoselon

Reputation: 2811

Why does VB close the console window too soon?

I'm learning visual Basic, and i want to show a windows console with Hola mundo, like this:

Module Greeting

   Sub Main()
       Console.WriteLine('Hola mundo')
   End Sub

End Module

But it run program, and show windows console and close fast, Why ? , something missed ?

Upvotes: 0

Views: 85

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112772

VB closes the console as soon as the program is terminated, i.e. the last statement in Sub Main() was executed. Therefore add a command waiting for a key press

Console.WriteLine('Hola mundo')
Console.ReadKey()

Now the console stays open until the user presses some key. If you want him to press Enter instead, replace Console.ReadKey() by Console.ReadLine().

Upvotes: 2

Related Questions