English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

when i write a console application such as below
Module Module1

Sub Main()
Dim Product As Integer = 2

While Product <= 1000
Console.Write("{0}", Product)
Product = Product * 2
End While
Console.WriteLine()

Console.WriteLine("The smallest power of two Greater than 1000 is {0}", Product)
End Sub

End Module

when i run it, it only pops up the black command window without giving me the chance to see the results. how can i stop it.

also if i change the name Module1 to anything else, the program says its missing main module, why?

2007-07-17 05:22:01 · 2 answers · asked by Sempeho 2 in Computers & Internet Programming & Design

2 answers

A console application has some very constraining rules.

If you wrote this application as anything BUT a console app, it would work.

If you add some code to wait until you press a key right after the Console.WriteLine but just before the End Sub, then the screen will stay up until you hit a key.

The reason its disappearing right now is because as soon as the computations and display are done, the program terminates.

2007-07-17 05:26:15 · answer #1 · answered by Scotty Doesnt Know 7 · 0 0

ctrl + f5

or

click debug, start without debugging.

or you can add this line at the end of your code
Console.readline()

2007-07-17 12:27:58 · answer #2 · answered by nino 2 · 0 0

fedest.com, questions and answers