Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
Public Function GetNISExchangeRate(Optional dtDate As Date = #1/1/1900#, Optional strCurr As String = "01") As Double
Dim strURL As String
Dim strResult As String
Dim pos As Long
Dim strSearch As String
Dim dtPreviousDate As Date
Dim i As Integer
strSearch = Chr(60) & "RATE" & Chr(62)
If dtDate = #1/1/1900# Then
dtDate = Date
End If
Select Case strCurr
Case "01", "02", "03", "05", "06", "12", "17", "18", "27", "28", "31", "69", "70", "79"
Case Else
MsgBox "קוד מטבע לא חוקי!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
Exit Function
End Select
If IsConnected Then
strURL = "http://www.boi.org.il/currency.xml?rdate=" & Format(IIf(dtPreviousDate > 1, dtPreviousDate, dtDate), "YYYYMMDD") & "&curr=" & strCurr
strResult = GetHTML(strURL)
If InStr(1, strResult, strSearch) < 1 Then
For i = 1 To 6
dtPreviousDate = dtDate - i
strURL = "http://www.boi.org.il/currency.xml?rdate=" & Format(dtPreviousDate, "YYYYMMDD") & "&curr=" & strCurr
strResult = GetHTML(strURL)
If InStr(1, strResult, strSearch) > 0 Then Exit For
Next i
End If
Else
MsgBox "לא זוהה חיבור לאינטרמת!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
End If
If Len(strResult) > 0 Then
pos = InStr(1, strResult, strSearch, vbTextCompare)
If pos > -1 Then
GetNISExchangeRate = ExtractNumber(Mid(strResult, pos + Len(strSearch), 5)) ' / 1000
End If
End If
End Function
Function IsConnected() As Boolean
Dim Stat As Long
IsConnected = (InternetGetConnectedState(Stat, 0&) <> 0)
End Function
Function GetHTML(strURL As String) As String
Dim HTML As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", strURL, False
.Send
GetHTML = .ResponseText
End With
End Function
Function ExtractNumber(strText As String)
Dim iCount As Integer, i As Integer
Dim lNum As String
For iCount = Len(strText) To 1 Step -1
If IsNumeric(Mid(strText, iCount, 1)) Then
i = i + 1
lNum = Mid(strText, iCount, 1) & lNum
Else
If Mid(strText, iCount, 1) = Chr(46) Then
i = i + 1
lNum = Mid(strText, iCount, 1) & lNum
End If
End If
If i = 1 Then lNum = CDbl(Mid(lNum, 1, 1))
Next iCount
ExtractNumber = CDbl(lNum)
End Function
Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
Public Function GetNISExchangeRate(Optional dtDate As Date = #1/1/1900#, Optional strCurr As String = "01") As Double
Dim strURL As String
Dim strResult As String
Dim pos As Long
Dim strSearch As String
Dim dtPreviousDate As Date
Dim i As Integer
strSearch = Chr(60) & "RATE" & Chr(62)
If dtDate = #1/1/1900# Then
dtDate = Date
End If
Select Case strCurr
Case "01", "02", "03", "05", "06", "12", "17", "18", "27", "28", "31", "69", "70", "79"
Case Else
MsgBox "קוד מטבע לא חוקי", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
Exit Function
End Select
If IsConnected Then
strURL = "http://www.boi.org.il/currency.xml?rdate=" & Format(IIf(dtPreviousDate > 1, dtPreviousDate, dtDate), "YYYYMMDD") & "&curr=" & strCurr
strResult = GetHTML(strURL)
If InStr(1, strResult, strSearch) < 1 Then
For i = 1 To 6
dtPreviousDate = dtDate - i
strURL = "http://www.boi.org.il/currency.xml?rdate=" & Format(dtPreviousDate, "YYYYMMDD") & "&curr=" & strCurr
strResult = GetHTML(strURL)
If InStr(1, strResult, strSearch) > 0 Then Exit For
Next i
End If
Else
MsgBox "לא זוהה חיבור לאינטרנט!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
End If
If Len(strResult) > 0 Then
pos = InStr(1, strResult, strSearch, vbTextCompare)
If pos > -1 Then
GetNISExchangeRate = ExtractNumber(Mid(strResult, pos + Len(strSearch), 5)) ' / 1000
End If
End If
End Function
Function IsConnected() As Boolean
Dim Stat As Long
IsConnected = (InternetGetConnectedState(Stat, 0&) <> 0)
End Function
Function GetHTML(strURL As String) As String
Dim HTML As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", strURL, False
.Send
GetHTML = .ResponseText
End With
End Function
Function ExtractNumber(strText As String)
Dim iCount As Integer, i As Integer
Dim lNum As String
For iCount = Len(strText) To 1 Step -1
If IsNumeric(Mid(strText, iCount, 1)) Then
i = i + 1
lNum = Mid(strText, iCount, 1) & lNum
Else
If Mid(strText, iCount, 1) = Chr(46) Then
i = i + 1
lNum = Mid(strText, iCount, 1) & lNum
End If
End If
If i = 1 Then lNum = CDbl(Mid(lNum, 1, 1))
Next iCount
ExtractNumber = CDbl(lNum)
End Function
נכתב ע"י moishy;1322602:מבדיקות שערכתי על מחשבים נוספים מתברר ש...
הקוד מתחיל לעבוד כראוי לאחר פתיחת הקישור באופן ידני בדפדפן. נכון לרגע זה אין לי הסבר לתופעה.
Function GetRate(AtDate As String, curr As String) As Double
Dim doc As New MSXML2.DOMDocument60
doc.async = False
doc.Load ("http://www.boi.org.il/currency.xml?rdate=" & AtDate & "&curr=" & curr)
GetRate = doc.SelectSingleNode(".//RATE").Text
End Function
Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
Function GetNISExchangeRate(Optional dtDate As Date = #1/1/1900#, Optional strCurr As String = "01") As Double
Dim objXMLDoc As Object
Dim objNode As Object
Dim strUrl As String
Dim dtPreviousDate As Date
Dim i As Long
Set objXMLDoc = CreateObject("MSXML2.DOMDocument.6.0")
If dtDate = #1/1/1900# Then
dtDate = Date
End If
Select Case strCurr
Case "01", "02", "03", "05", "06", "12", "17", "18", "27", "28", "31", "69", "70", "79"
Case Else
MsgBox "קוד מטבע לא חוקי", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
Exit Function
End Select
If IsConnected Then
strUrl = "http://www.boi.org.il/currency.xml?rdate=" & Format(IIf(dtPreviousDate > 1, dtPreviousDate, dtDate), "YYYYMMDD") & "&curr=" & strCurr
objXMLDoc.async = False
objXMLDoc.Load strUrl
Set objNode = objXMLDoc.SelectSingleNode("//RATE")
Do Until Not objNode Is Nothing
dtPreviousDate = dtDate - i
strUrl = "http://www.boi.org.il/currency.xml?rdate=" & Format(dtPreviousDate, "YYYYMMDD") & "&curr=" & strCurr
objXMLDoc.Load strUrl
Set objNode = objXMLDoc.SelectSingleNode("//RATE")
i = i + 1
Loop
Else
MsgBox "לא זוהה חיבור לאינטרנט!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
End If
GetNISExchangeRate = objXMLDoc.SelectSingleNode("//RATE").Text
End Function
Function IsConnected() As Boolean
Dim Stat As Long
IsConnected = (InternetGetConnectedState(Stat, 0&) <> 0)
End Function
Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
Function GetNISExchangeRate(Optional dtDate As Date = #1/1/1900#, Optional strCurr As String = "01") As Double
Dim objXMLDoc As Object
Dim objNode As Object
Dim strUrl As String
Dim dtPreviousDate As Date
Dim i As Long
Set objXMLDoc = CreateObject("MSXML2.DOMDocument.6.0")
If dtDate = #1/1/1900# Then
dtDate = Date
End If
Select Case strCurr
Case "01", "02", "03", "05", "06", "12", "17", "18", "27", "28", "31", "69", "70", "79"
Case Else
MsgBox "קוד מטבע לא חוקי", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
Exit Function
End Select
If IsConnected Then
strUrl = "http://www.boi.org.il/currency.xml?rdate=" & Format(IIf(dtPreviousDate > 1, dtPreviousDate, dtDate), "YYYYMMDD") & "&curr=" & strCurr
With CreateObject("InternetExplorer.Application")
.Visible = False
.Navigate strUrl
Do Until .Busy = False And .ReadyState = 4
DoEvents
Loop
.Quit
End With
objXMLDoc.async = False
objXMLDoc.Load strUrl
Set objNode = objXMLDoc.SelectSingleNode("//RATE")
Do Until Not objNode Is Nothing
dtPreviousDate = dtDate - i
strUrl = "http://www.boi.org.il/currency.xml?rdate=" & Format(dtPreviousDate, "YYYYMMDD") & "&curr=" & strCurr
objXMLDoc.Load strUrl
Set objNode = objXMLDoc.SelectSingleNode("//RATE")
i = i + 1
Loop
Else
MsgBox "ìà æåää çéáåø ìàéðèøðè!", vbCritical + vbMsgBoxRtlReading + vbMsgBoxRight
End If
GetNISExchangeRate = objXMLDoc.SelectSingleNode("//RATE").Text
End Function
Function IsConnected() As Boolean
Dim Stat As Long
IsConnected = (InternetGetConnectedState(Stat, 0&) <> 0)
End Function
rhon.co.il
מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!
חלה שגיאה בשליחה. נסו שוב!
לוח לימודים
מסלולי לימוד שאפשר להצטרף
אליהם ממש עכשיו:
תהילים פרק כה
אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
הנושאים החמים