[AccessD] Exchange Rate - Currency Converter thingy

Salakhetdinov Shamil mcp2004 at mail.ru
Fri Jun 29 04:07:31 CDT 2012


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


Fri, 29 Jun 2012 12:00:35 +0400 от Salakhetdinov Shamil <mcp2004 at mail.ru>:
Hi All --

Here is another method for the subject task solution.
It uses XSL transformation.
Of course it's a kind of overuse of XML/XSL transformation power for this simple task but it's a generic solution for any XML/XSL transformations - just change source XML and transformation XSL...

Option Explicit
Public Sub TestMe()
'
' XML & XPath info sources
'
' http://msdn.microsoft.com/en-us/library/aa468547.aspx
' http://msdn.microsoft.com/en-us/library/aa468565
' http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/a3d6be0c-537a-4467-994a-1e258634ad0c
' http://www.xml.com/pub/a/1999/01/namespaces.html
' http://stackoverflow.com/questions/4550212/parsing-xml-in-vba?rq=1
'
' DOMDocument.tranformNode method information
' http://msdn.microsoft.com/en-us/library/windows/desktop/ms761399(v=vs.85).aspx
'
<<< skipped >>>



More information about the AccessD mailing list