Пока идея выглядит так:
1. Соединение с сервером;
2. Запрос документа;
3. Сохранение на диск;
4. Открыть как текст;
5. Долго и нудно перебирать теги и выковыривать значения.
Ужас
Может есть какие-то предложения, как упростить.




Function GetInetCBRRates(ByVal CurrencyID As String, Optional ByVal RateDate) As Currency
Dim inet As Object, itbl As Object, U As String
Dim curID As String, curCode As String, curName As String, curK As Long, curRate As Currency
Dim R As Long, C As Long, Z As String, fFind As Boolean
Const URL As String = "http://www.cbr.ru/currency_base/D_print.asp?date_req=#D#/#M#/#Y#"
Const READYSTATE_UNINITIALIZED As Long = 0&
Const READYSTATE_LOADING As Long = 1&
Const READYSTATE_LOADED As Long = 2&
Const READYSTATE_INTERACTIVE As Long = 3&
Const READYSTATE_COMPLETE As Long = 4&
If IsMissing(RateDate) Then RateDate = Now Else RateDate = CDate(RateDate)
U = URL
U = Replace(U, "#D#", Format$(RateDate, "DD"))
U = Replace(U, "#M#", Format$(RateDate, "MM"))
U = Replace(U, "#Y#", Format$(RateDate, "YYYY"))
Set inet = CreateObject("InternetExplorer.Application")
inet.Navigate U
Do Until inet.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Set itbl = inet.Document.All.Tags("TABLE").Item(2)
For R = 1 To itbl.Rows.Length - 1
For C = 1 To itbl.Rows(R).Cells.Length
Z = itbl.Rows(R).Cells(C - 1).InnerText
Select Case C
Case 1
curID = Z
Case 2
curCode = Z
Case 3
Z = Replace(Z, " ", "")
Z = Replace(Z, ",", ".")
curK = CLng(Z)
If curK = 0 Then curK = 1
Case 4
curName = Z
Case 5
Z = Replace(Z, " ", "")
Z = Replace(Z, ",", ".")
curRate = CCur(Z)
End Select
If C = 5 Then
If CurrencyID = curID Then fFind = True
If UCase$(CurrencyID) = UCase$(curCode) Then fFind = True
End If
If fFind Then Exit For
Next C
If fFind Then Exit For
Next R
Set itbl = Nothing
inet.Quit
Set inet = Nothing
If fFind Then GetInetCBRRates = curRate / curK
End Function

Сейчас этот форум просматривают: Yandex-бот и гости: 20