2014-02-17 103 views
-1

我在VB6中有一個簡單的程序。我有兩個文本框和一個列表框。我已經把日期範圍放在文本框中,結果出現在列表框中。例如一個文本框02/05/2012和另一個文本框02/10/2012。結果進來列表框中獲取在給定兩個日期之間的範圍

02/05/2012 02/06/2012 02/07/2012 02/08/2012 2012年2月9日 02/10/2012

任何一個引導我

回答

-1

如果您使用的是JavaScript,然後再看到這樣一個

function (startDate, endDate, addFn, interval) { 

addFn = addFn || Date.prototype.addDays; 
interval = interval || 1; 

var retVal = []; 
var current = new Date(startDate); 

while (current <= endDate) { 
    retVal.push(new Date(current)); 
    current = addFn.call(current, interval); 
} 

return retVal; 

} 
2
Dim dtStart As Date, dtEnd As Date 

If Not IsDate(Text1) Then 
    MsgBox "Text1 does not contain a valid date" 
    ' Exit Sub/Function 
End If 

If Not IsDate(Text2) Then 
    MsgBox "Text2 does not contain a valid date" 
    ' Exit Sub/Function 
End If 

dtStart = CDate(Text1) 
dtEnd = CDate(Text2) 

' Clear the listbox 
List1.Clear 

Dim d As Date 
For d = dtStart To dtEnd 
    List1.AddItem d 
Next 
相關問題