我一直在尝试使用以下代码下载文件:
Private Sub cmdGetData_Click()
Dim iBSEDay As String
Dim i As Date
'Date pickers: DTPickerStart for first date & DTPickerEnd for end date
For i = DTPickerStart.Value To DTPickerEnd.Value
iBSEDay = Format$(i, "dd") + Format$(i, "mm") + Format$(i, "yy")
Call ModuleDownloadFile.DownloadFile ("http://www.bseindia.com/download/BhavCopy/Equity/eq" + iBSEDay + "csv.zip", "E:\" + "eq" + iBSEDay + "csv.zip")
Next i
End Sub
模块:
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function DownloadFile(sSourceUrl As String, sLocalFile As String) As Boolean
DownloadFile = URLDownloadToFile(0&, sSourceUrl, sLocalFile, BINDF_GETNEWESTVERSION,_
0&) = ERROR_SUCCESS
End Function
“---------------------------------------------- ----------------------------
查询: 网站bseindia.com在股票交易所关闭时不会记录任何数据。 (周末或国定假日)
如果我尝试直接在网页上下载http://www.bseindia.com/download/BhavCopy/Equity/eq300613_csv.zip(星期日30-06-13),则不会下载。 如果我尝试直接在网页上下载eq010713_csv.zip(星期一01-07-13)而不是eq300613_csv.zip,它会正确下载文件。
但是当我运行我的程序时,它会下载这两个文件。下载的文件(eq300613_csv.zip)不是归档文件(仅在周末或网站上没有数据的那一天发生)。
如果上述网站上没有特定日期的数据,有人可以帮我在VB 6.0中生成错误消息吗?
由于