一次秀多個訊息 ! 訊息炸彈 !

一次秀多個訊息 ! 訊息炸彈 !

如何能一次秀多個連續訊息

' Command Button Click
事件
Private Sub Command1_Click()
ShowMessage "
訊息內容 1", "Title1", 0
ShowMessage "
訊息內容 2", "Title2", 0
ShowMessage "
訊息內容 3", "Title3", 0
ShowMessage "
訊息內容 4", "Title4", 0
End Sub

'
一次秀多個訊息 Procedure ( 可做出類似訊息炸彈 )
' MessageString
訊息內容
' MessageTitle
訊息視窗的 Title Caption
' DelayTime
訊息顯示時間 ( 時間到訊息會自己關閉 , 若設 0 則訊息窗不會自動關閉 )
Private Sub ShowMessage(MessageString As String, MessageTitle As String, _
Optional DelayTime As Integer)
Randomize
Dim fnum As Integer
Dim tmpDir As String, MessageSyntax As String, MessageFileName As String
fnum = FreeFile '
取得可用的檔案代碼
tmpDir = Environ("TEMP") ' 取得 Windows Temp 路徑
If Right(tmpDir, 1) <> "\" Then tmpDir = tmpDir & "\"
MessageFileName = tmpDir & Rnd(3388) & ".vbs" '
用亂數產生 vbs 檔名 , 以供後續使用

'
這段是要寫到 vbs 檔案中的內容
'
建立 WScript 物件的 Shell 類別 , 使用 Popup 方法來 Show 訊息
MessageSyntax = "Call CreateObject(""WScript.Shell"").Popup(""" & _
MessageString & """," & _
DelayTime & ",""" & _
MessageTitle & """, 0)"

'
將內容寫至 VBS
Open MessageFileName For Output Shared As fnum
Print #fnum, MessageSyntax
Close fnum

'
底下迴圈是為了給 IO 一些時間寫檔
Do Until (Dir(MessageFileName) <> "" And FileLen(MessageFileName) > 38)
Loop

'
Shell 呼叫 WScript 來執行 VBS 以秀訊息
Shell "WSCript " & MessageFileName, vbNormalFocus
End Sub