Ok, so I have figured it out!
Imports System.Windows.Forms
Module VBModule
Sub Main()
Application.Run(New Form1())
End Sub
Friend Class Form1 Inherits Form
Private btnClickMe As New Button()
Public Sub New()
Me.Text = "My Simple Form"
btnClickMe.Text = "Click Me"
AddHandler btnClickMe.Click, AddressOf btnClickMe_Click
Me.Controls.Add(btnClickMe)
Me.Visible = true
End Sub
Private Sub btnClickMe_Click(sender As Object, e As EventArgs)
MessageBox.Show("Button was clicked!")
End Sub
End Class
End Module
And then instead of running it by hitting "Run" you need to click the little down arrow on the Rub button and choose "Run with display screen (beta)" and it will actually work. Hitting "Run" doesn't work because it generates this exception:
Unhandled Exception:
The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
And that means it is trying to use an XWindows server to display the window. But the XWindows thing doesn't work (I tried many times) so you need to use the built-in "Run with display screen (beta)" option.