Hello World in VB.NET Forms
suggest changeTo show a message box when the form has been shown:
Public Class Form1 Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown MessageBox.Show("Hello, World!") End Sub End Class To show a message box before the form has been shown: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load MessageBox.Show("Hello, World!") End Sub End Class
Load() will be called first, and only once, when the form first loads. Show() will be called every time the user launches the form. Activate() will be called every time the user makes the form active.
Load() will execute before Show() is called, but be warned: calling msgBox() in show can cause that msgBox() to execute before Load() is finished. It is generally a bad idea to depend on event ordering between Load(), Show(), and similar.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents