A Sample VB Console Application
To create a sample visual basic console application, follow below steps,Open visual studio
File> New Project> Visual Basic> Console Application
Give a name, say ConsoleApplication1, for your application and click OK.
A project will be created and module.vb file will opened as below.
Module Module1
Sub Main()
End Sub
End Module
To print hello world on console we will add
Console.WriteLine("Hello World")
inside Main() subroutine.
On running the application, we will get nothing. Actually the code is executed, hello world is printed but console window is closed after this.
To prevent closing of the console window, we will add
Console.ReadKey()
which will wait for user input.
Module Module1
Sub Main()
Console.WriteLine("Hello World")
Console.ReadKey()
End Sub
End Module
Now run the application
No comments:
Post a Comment