2017-01-09 65 views
0

我們有一些代碼在處理之前根據3個不同的標準檢查每個傳入文件(不是週末,不是在下午6點之後,也不是假期)。這就是說,我需要弄清楚如何讓它現在檢查半小時(粗體部分)。我曾嘗試添加+ mRelease > 30以及AND mRelease > 30,並且都失敗了。我一直在目前改變這一行計算文件的新發布時間

Do While (WeekDay(dRelease) = 1) OR (WeekDay(dRelease) = 7) OR (UBound(fHoliday) > -1) OR (tRelease >17) 

這裏是代碼到位:

result = "" 
dRelease = Now 
tRelease = CStr(Hour(Now)) 
mRelease = CStr(Minute(Now)) 

aHoliday = Array("01/02/2017","01/16/2017","05/29/2017","07/04/2017","09/04/2017","10/09/2017","11/23/2017","11/24/2017","12/25/2017","12/26/2017") 
dNow = CStr(DatePart("m",Date)) + "/" + CStr(DatePart("d",Date)) + "/" + CStr(DatePart("yyyy",Date)) 
dMonth = "0" + CStr(Month(dRelease)) 
dDay = "0" + CStr(Day(dRelease)) 
dYear = CStr(Year(dRelease)) 
fHoliday = Filter(aHoliday,Right(dMonth,2) + "/" + Right(dDay,2) + "/" + dYear) 
'fHoliday = Filter(aHoliday,dNow) 
'result = UBound(fHoliday) 
'result = Left(dRelease,10) 
'result = CStr(DatePart("m",Date)) + "/" + CStr(DatePart("d",Date)) + "/" + CStr(DatePart("yyyy",Date)) 
'While release date is a weekend, or release date is a holiday 
Do While (WeekDay(dRelease) = 1) OR (WeekDay(dRelease) = 7) OR (UBound(fHoliday) > -1) OR (tRelease >17) 
    'increase release date by 1 
    dRelease = dRelease + 1 
    'result = dRelease 
    'check for holiday 
    dMonth = "0" + CStr(Month(dRelease)) 
    dDay = "0" + CStr(Day(dRelease)) 
    dYear = CStr(Year(dRelease)) 
    'fHoliday = Filter(aHoliday,Left(dRelease,10)) 
    fHoliday = Filter(aHoliday,Right(dMonth,2) + "/" + Right(dDay,2) + "/" + dYear) 
    tRelease = 00 
Loop 

'Format the release date to the Esker deferred date/time standard. 
dMonth = "0" + CStr(Month(dRelease)) 
dDay = "0" + CStr(Day(dRelease)) 
dYear = CStr(Year(dRelease)) 
dtCurrent = Right(dMonth,2) + "/" + Right(dDay,2) + "/" + dYear 

If dRelease > Now Then 
    tRelease = "00:" + mRelease 
Else 
    tRelease = CStr(Hour(Now)) + ":" + CStr(Minute(Now)) 
End If 

result = dtCurrent + " " + tRelease 
+0

VBScript和VB .NET不一樣。這是什麼? –

+1

半小時應該完成什麼?文件是否只能在某個特定小時的前半段才能完成? –

+0

目前它檢查時間。如果是在「tRelease> 17」之後(I.E. 18:00),它會將文件保存到午夜之後。我現在需要的就是說,如果是在16:30之後,請保留該文件。 –

回答

0

更改此:

Do While (WeekDay(dRelease) = 1) OR (WeekDay(dRelease) = 7) OR (UBound(fHoliday) > -1) OR (tRelease >17) 
    ... 
Loop 

成這樣:

If (WeekDay(dRelease) = 1) Or (WeekDay(dRelease) = 7) Or (UBound(fHoliday) > -1) Or (Time > CDate("16:30")) Then 
    ... 
End If 
+0

我收到此錯誤: '溢出:'dRelease' @(22,3):Microsoft VBScript運行時錯誤,完整的腳本源代碼是:' –

+0

'Do While'應該可能是'If'。否則,我會期望腳本過度增加'dRelease'直到日期改變或變量溢出。以先到者爲準。 –