home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.UserControl RateControl
- ClientHeight = 3600
- ClientLeft = 0
- ClientTop = 0
- ClientWidth = 4800
- ScaleHeight = 3600
- ScaleWidth = 4800
- Begin VB.ListBox CurrencyList
- Height = 2790
- Left = 15
- TabIndex = 0
- Top = 15
- Width = 2415
- End
- Attribute VB_Name = "RateControl"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- Dim AllRates As New Collection
- Dim m_LastUpdate As Date
- 'Event Declarations:
- Event Click() 'MappingInfo=CurrencyList,CurrencyList,-1,Click
- Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
- Event DblClick() 'MappingInfo=CurrencyList,CurrencyList,-1,DblClick
- Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
- Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=CurrencyList,CurrencyList,-1,KeyDown
- Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
- Event KeyPress(KeyAscii As Integer) 'MappingInfo=CurrencyList,CurrencyList,-1,KeyPress
- Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
- Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=CurrencyList,CurrencyList,-1,KeyUp
- Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
- Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=CurrencyList,CurrencyList,-1,MouseDown
- Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
- Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=CurrencyList,CurrencyList,-1,MouseMove
- Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
- Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=CurrencyList,CurrencyList,-1,MouseUp
- Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
- Public Event RatesRead()
- Public Event DLoadError(ErrNumber As Long, ErrDescription As String)
- Private Sub UserControl_Resize()
- CurrencyList.Enabled = False
- CurrencyList.Width = UserControl.Width
- CurrencyList.Height = UserControl.Height
- CurrencyList.Enabled = True
- End Sub
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=CurrencyList,CurrencyList,-1,BackColor
- Public Property Get BackColor() As OLE_COLOR
- Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
- BackColor = CurrencyList.BackColor
- End Property
- Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
- CurrencyList.BackColor() = New_BackColor
- PropertyChanged "BackColor"
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=CurrencyList,CurrencyList,-1,ForeColor
- Public Property Get ForeColor() As OLE_COLOR
- Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
- ForeColor = CurrencyList.ForeColor
- End Property
- Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
- CurrencyList.ForeColor() = New_ForeColor
- PropertyChanged "ForeColor"
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=UserControl,UserControl,-1,Enabled
- Public Property Get Enabled() As Boolean
- Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
- Enabled = UserControl.Enabled
- End Property
- Public Property Let Enabled(ByVal New_Enabled As Boolean)
- UserControl.Enabled() = New_Enabled
- PropertyChanged "Enabled"
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=CurrencyList,CurrencyList,-1,Font
- Public Property Get Font() As Font
- Attribute Font.VB_Description = "Returns a Font object."
- Attribute Font.VB_UserMemId = -512
- Set Font = CurrencyList.Font
- End Property
- Public Property Set Font(ByVal New_Font As Font)
- Set CurrencyList.Font = New_Font
- PropertyChanged "Font"
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MappingInfo=CurrencyList,CurrencyList,-1,Refresh
- Public Sub Refresh()
- Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
- CurrencyList.Refresh
- End Sub
- Private Sub CurrencyList_Click()
- RaiseEvent Click
- End Sub
- Private Sub CurrencyList_DblClick()
- RaiseEvent DblClick
- End Sub
- Private Sub CurrencyList_KeyDown(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyDown(KeyCode, Shift)
- End Sub
- Private Sub CurrencyList_KeyPress(KeyAscii As Integer)
- RaiseEvent KeyPress(KeyAscii)
- End Sub
- Private Sub CurrencyList_KeyUp(KeyCode As Integer, Shift As Integer)
- RaiseEvent KeyUp(KeyCode, Shift)
- End Sub
- Private Sub CurrencyList_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseDown(Button, Shift, X, Y)
- End Sub
- Private Sub CurrencyList_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseMove(Button, Shift, X, Y)
- End Sub
- Private Sub CurrencyList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- RaiseEvent MouseUp(Button, Shift, X, Y)
- End Sub
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MemberInfo=3,1,2,0
- Public Property Get LastUpdate() As Date
- Attribute LastUpdate.VB_MemberFlags = "400"
- LastUpdate = m_LastUpdate
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MemberInfo=8,1,2,0
- Public Property Get Count() As Long
- Attribute Count.VB_MemberFlags = "400"
- Count = AllRates.Count
- End Property
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MemberInfo=13
- Public Function GetCurrencyName(index As Long) As String
- If index < 1 Or index > AllRates.Count Then
- GetCurrencyName = ""
- Else
- cName = CurrencyList.List(index - 1)
- sPos = InStr(cName, Chr(9))
- If sPos = 0 Then
- GetCurrencyName = ""
- Else
- GetCurrencyName = Left(cName, sPos - 1)
- End If
- End If
- End Function
- 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
- 'MemberInfo=2
- Public Function GetCurrencyRate(currencyName As String) As Currency
- On Error GoTo UnknownRate
- GetCurrencyRate = AllRates.Item(currencyName)
- Exit Function
- UnknownRate:
- getcurrency = -1
- End Function
- 'Initialize Properties for User Control
- Private Sub UserControl_InitProperties()
- m_LastUpdate = m_def_LastUpdate
- m_Count = m_def_Count
- End Sub
- 'Load property values from storage
- Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
- CurrencyList.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
- CurrencyList.ForeColor = PropBag.ReadProperty("ForeColor", &H80000008)
- UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
- Set CurrencyList.Font = PropBag.ReadProperty("Font", Ambient.Font)
- m_LastUpdate = PropBag.ReadProperty("LastUpdate", m_def_LastUpdate)
- m_Count = PropBag.ReadProperty("Count", m_def_Count)
- End Sub
- 'Write property values to storage
- Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
- Call PropBag.WriteProperty("BackColor", CurrencyList.BackColor, &H8000000F)
- Call PropBag.WriteProperty("ForeColor", CurrencyList.ForeColor, &H80000008)
- Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
- Call PropBag.WriteProperty("Font", CurrencyList.Font, Ambient.Font)
- Call PropBag.WriteProperty("LastUpdate", m_LastUpdate, m_def_LastUpdate)
- Call PropBag.WriteProperty("Count", m_Count, m_def_Count)
- End Sub
- Public Function DownloadRates(RatesURL As String)
- On Error GoTo DLoadError
- AsyncRead RatesURL, vbAsyncTypeFile, "Rates"
- Exit Function
- DLoadError:
- RaiseEvent DLoadError(1024, "Could not download currency rates.")
- End Function
- Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty)
- Dim FileName As String
- On Error GoTo DLoadError
- If AsyncProp.PropertyName = "Rates" Then
- FileName = AsyncProp.Value
- ReadRates FileName
- End If
- Exit Sub
- DLoadError:
- RaiseEvent DLoadError(1025, "Error in Downloading rates ")
- End Sub
- Private Sub ReadRates(FileName As String)
- Dim FNum As Integer
- Dim currencyName As String, currencyValue As Currency
- Dim DTLine As String
- Dim i As Long
- FNum = FreeFile
- CurrencyList.Clear
- For i = AllRates.Count To 1 Step -1
- AllRates.Remove i
- Next
- On Error GoTo ReadError
- Open FileName For Input As FNum
- Input #FNum, DTLine
- m_LastUpdate = DTLine
- While Not EOF(FNum)
- Input #FNum, currencyName, currencyValue
- CurrencyList.AddItem currencyName & Chr(9) & Format(currencyValue, "#.000")
- AllRates.Add Str(currencyValue), currencyName
- Wend
- Close #FNum
- RaiseEvent RatesRead
- Exit Sub
- ReadError:
- RaiseEvent DLoadError(1025, "Unkown data format")
- End Sub
-