VB - Forms - Unload a form in the Form_Load() event
If you putthe command "Unload me" in the VB Form_Load() event it generates a runtime error "The object was unloaded".
Instead use the Postmessage API to post a WM_CLOSE message to it...
VB Code:
Option Explicit
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Form_Load()
PostMessage Me.hwnd, WM_CLOSE, 0, 0
End Sub