Board logo

標題: Application.InputBox 可否設等待時間?? [打印本頁]

作者: t8899    時間: 2015-10-21 13:12     標題: Application.InputBox 可否設等待時間??

Application.InputBox 可否設等待時間??
假如等待5秒沒輸入,自動以"n"輸入
作者: PKKO    時間: 2015-10-21 15:14

好奇+1,這我之前也研究過,沒有找到答案,若沒有輸入會一直卡在那邊,後續的程式碼無法繼續運行
作者: 准提部林    時間: 2015-10-24 12:03

Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
    ByVal nIDEvent As Long, ByVal uElaspe As Long, ByVal lpTimerFunc As Long) As Long

Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Public PopTime As Long

Sub Test()
Dim x
PopTime = SetTimer(0, 0, 5000, AddressOf CloseInputBox)
x = Application.InputBox("請輸入")
If x = "" Then x = "n"
MsgBox x
KillTimer 0, PopTime
End Sub

Sub CloseInputBox(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)
Application.SendKeys "~", True
KillTimer 0, PopTime
End Sub

網路找到的,試試~~
作者: t8899    時間: 2015-10-24 19:21

Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
    ByVal nIDEvent As Long, By ...
准提部林 發表於 2015-10-24 12:03


thanks!
作者: PKKO    時間: 2015-10-25 18:50

回復 3# 准提部林


    准大好讚!'晚點測試一下~




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)