不好意思,今晚回来有点晚- '//保存我为new.vbs,然后运行即可
-
- Dim intDays,intLines,strLast,strOut
- Dim FirstDate,i,outDate,newDate,f
-
- strLast="XXX" '//此处为日期后面的文本后面
- FirstDay=InputBox("请输入第一天,格式为 年-月-日 如"&vbCrLf&"2011-1-1:")
- intDays=InputBox("请输入时间间隔(天):")
- intLines=InputBox("请输入行数:")
-
- intDays=intDays+1
- strOut=FormatDate(FirstDay) & strLast
- newDate=DateAdd("d",intDays,FirstDay)
-
- For i=1 To intLines-1
- strOut=strOut & vbCrLf & FormatDate(newDate) & strLast
- newDate=DateAdd("d",intDays,newDate)
- Next
-
- Set f=CreateObject("scripting.filesystemobject").CreateTextFile("1.txt",True)
- f.Write strOut
- f.Close
- MsgBox "保存在当前目录下1.TXT"
- Set f=Nothing
-
-
- '//定义函数判断日期格式
- Function FormatDate(strDate)
- Dim strYear,strMonth,strDay
- strYear=DatePart("yyyy",strDate)
- strMonth=FormatNum(DatePart("m",strDate))
- strDay=FormatNum(DatePart("d",strDate))
- FormatDate=strYear & strMonth & strDay
- End Function
-
- '//定义过程判断日期格式2
- Function FormatNum(intNum)
- If Len(intNum)=1 Then
- FormatNum="0" & intNum
- Else
- FormatNum=intNum
- End If
- End Function
复制代码
|