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 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents