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 = Mid(strResult, pos + Len(strSearch), 5)
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
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
rhon.co.il
מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!
חלה שגיאה בשליחה. נסו שוב!
לוח לימודים
מסלולי לימוד שאפשר להצטרף
אליהם ממש עכשיו:
תהילים פרק כה
אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
הנושאים החמים