标题: 自己改的一个简单的脚本,请高手帮忙看看为什么行不通 [打印本页] 作者: hepingisme 时间: 2006-10-27 17:34 标题: 自己改的一个简单的脚本,请高手帮忙看看为什么行不通 Sub Main
Dim Result As Integer
'Initially Recorded: 2006-10-27 16:49:13
'Script Name: 画图
Global iTime as Integer
Declare Function TimedDlgFunc(id As String, Action As Integer, Suppvalue As Long) As Integer
Declare Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer
Function TimedDlgFunc(id As String, Action As Integer, Suppvalue As Long) As Integer
Static StartTime
Dim EndTime
Dim vTimeoutvalue as Variant
Select Case Action
Case 1 'Dialog box Initialization
StartTime = Timer
If StartTime + iTime >= 86400 Then
StartTime = 86400 - StartTime - iTime
End If
TimedDlgFunc = 1
Case 2 'Button pushed or any control changed (except typing in text or combo box)
Select Case Suppvalue
Case 1
DlgEnd -1
Case 2
DlgEnd 0
Case Else
TimedDlgFunc = 0
End Select
Case 3 'Change in text or combo box contents
TimedDlgFunc = 1
Case 4 'Change of control focus
TimedDlgFunc = 1
Case 5 'Idle state (return 0 to prevent this being continually called)
EndTime = Timer
If (EndTime - StartTime) >= iTime Then
DlgEnd -1
End If
vTimeoutvalue = Format(iTime - (EndTime - StartTime), "#.#")
DlgText DlgControlID("txtTimevalue"), CStr(vTimeoutvalue)
TimedDlgFunc = 1
End Select
End Function
Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer
Dim Result as Integer
Dim TotalTime As Integer
Dim sCmdText as String
Dim sTimeoutText as String
Dim vvalue as Variant
If IsMissing(vMsgCaption) Then
vMsgCaption = "SQAMsgBox"
End If
If IsMissing(vTimeOut) Then
vTimeOut = 20 'seconds
End If
sTimeoutText = "Timeout: "
'-----
Begin Dialog dlgMsgBox 200, 80, vMsgCaption, .TimedDlgFunc
GroupBox 5, 2, 190, 40, "", .grpMsgTxt
Text 15, 11, 175, 25, sMsgText, .txtMsgText
Text 15, 47, 180, 20, sCmdText, .txtCmdText
'--------------
Button 20, 60, 40, 14, "&OK", .btnOK
Button 140, 60, 40, 14, "&Cancel", .btnCancel
Text 78, 63, 30, 10, sTimeoutText, .txtTimeText
Text 108, 63, 20, 10, vTimeout, .txtTimevalue
End Dialog
'-----
Dim TimedDlg As dlgMsgBox
iTime = CInt(vTimeOut)
Result = Dialog(TimedDlg)
If Result = 2 Then
SQAMsgBox = sqaFail
Else
SQAMsgBox = sqaPass
End If
End Function
Sub Main
Dim Result As Integer
'Initially Recorded: 2006-10-27 16:49:13
'Script Name: »­Í¼