'以下代码放在模块里
Public 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
Public Const WM_SYSCOMMAND = &H112
Public Const SC_CLOSE = &HF060&
'以下代码放在form里
Private Sub Command1_Click()
PostMessage 句柄, WM_SYSCOMMAND, SC_CLOSE, 0
End Sub