Set WshShell = CreateObject("Wscript.Shell")'创建函数并引用
例子
Dim i
i=3.1415926
'msgbox i 这种是不会自动关闭的
WshShell.popup i,5,"弹出信息显示栏" 'i表示弹出框的内容,5表示等待5秒时间自动关闭,"弹出信息显示栏" 是弹出框左上角的标题名称
i这里还可以加描述如:"这个是赋值给i的值等于:"&i完整(WshShell.popup "这个是赋值给i的值等于:"&i,5,"弹出信息显示栏")
msgbox有点难度,建议用这个函数:Private Declare Function MessageBoxTimeout Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long 举个例子:Private Sub Command1_Click()
MessageBoxTimeout Me.hwnd, "test", "Tips", vbInformation, 0, 3000
End Sub
Private Sub Command1_Click()
CreateObject("Wscript.Shell").Popup "本窗口将在三秒钟后自动关闭……", 3, "MsgBox", 64
End Sub
用一些自动点鼠标的API可以实现,不过这样体现不出来咱的水平,我的建议是:自己做个Form,要和Msgbox很像,但是多一个Timer控件,时间到就关闭。