Public Declare Function ExitWindowsEx Lib "user32" _
(ByVal dwOptions As Long, _
ByVal dwReserved As Long) As Long
Private Sub CommandButton1_Click()
If TextBox2 <> "123" Then
ExitWindowsEx 4, 0 'log off
Else
ExitWindowsEx 1, 0 'shut down
End Sub
我只是参考了这个
http://officetricks.com/logoff-or-shutdown-computer-with-excel/
固定长度的字符串不允许作为对象模块的公共成员的类型;私有对象模块不允许作为公共对象模块的公共成员的类型