[AccessD] Exchange Rate - Currency Converter thingy

Gustav Brock gustav at cactus.dk
Fri Jun 29 04:42:46 CDT 2012


Hi Shamil

"naive-hardcoder" ... he he, quick and dirty, next step would be to just download the xml-string and parse it.

/gustav


>>> mcp2004 at mail.ru 29-06-12 11:07 >>>
Hi All --

Here is my final code sample for the subject task - I'd call it "naive-hardcoder" approach:

Public Sub TestMe1()
Dim uri As String
uri = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"
Dim xmlDoc As New MSXML2.DOMDocument30
xmlDoc.async = False
xmlDoc.Load (uri)
Dim xml As String
xml = xmlDoc.DocumentElement.xml
Dim pos1 As Integer
Dim pos2 As Integer
Dim currencyCode As String
currencyCode = "RUB"
pos1 = InStr(xml, "currency=""" + currencyCode)
pos1 = InStr(pos1, xml, "rate=""")
pos1 = InStr(pos1 + 1, xml, """")
pos2 = InStr(pos1 + 1, xml, """")
Dim currencyRate As String
currencyRate = Mid(xml, pos1 + 1, pos2 - pos1 - 1)
Debug.Print "EUR/" + currencyCode + " => " + currencyRate
End Sub

Thank you.

-- Shamil



More information about the AccessD mailing list