Hello World in VB.NET Forms

suggest change

To 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 runs first, and only once, when the form is first loaded. Shown runs each time the form is displayed. Activated runs each time the form becomes active.

Load runs before Shown, but a MessageBox in Shown can re-enter the message loop before Load has finished. Do not depend on the ordering of Load, Shown, and similar events.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents