Exontrol.ExChange - Information, Features

ExChange

Perform currency conversions. The ExChange library contains two COM objects, ExChange and ExChart. The ExChange is a COM object for performing conversions between a currency and hundreds of other international currencies. The ExChart component display the exchange rates between two international currencies into a given interval. As with any currency converter, it's vitally important that you have the latest exchange rates. That's why ExChange gets the rates from the Internet. The control supports adding manually the rates as well. As usual, no dependencies.

® ExChange is a trademark of Exontrol. All Rights Reserved.


Exontrol - Support

How to get support?

To keep your business applications running, you need support you can count on.

Here are few hints what to do when you're stuck on your programming:

  • Check out the samples - they are here to provide some quick info on how things should be done
  • Check out the how-to questions using the eXHelper tool
  • Check out the help - includes documentation for each method, property or event
  • Check out if you have the latest version, and if you don't have it send an update request here.
  • Submit your problem(question) here.

Don't forget that you can contact our development team if you have ideas or requests for new components, by sending us an e-mail at support@exontrol.com ( please include the name of the product in the subject, ex: exgrid ) . We're sure our team of developers will try to find a way to make you happy - and us too, since we helped.

Regards,
Exontrol Development Team

https://www.exontrol.com


ExChange object
The ExChange control supports the following properties and methods:

Name | Description
Convert | Converts the amount of CurFrom currency to CurTo currency.
Currencies | Gets the list of available currencies.
Date | Retrieves or sets the conversion date.
Debug | Queries a FXP server and gets the results.
Host | Specifies the FXP server address.
Port | Retrieves or sets the FXP server's port.
Timeout | Specifies the amount of time (in seconds) the control will wait for the server response.


property Convert

property ExChange.Convert ([Amount as Variant], [CurFrom as Variant], [CurTo as Variant]) as Double
Converts the amount of CurFrom currency to CurTo currency.

Type | Description
Amount as Variant | A numeric expression that indicates the amount being converted. If the argument is missing, 1.00 is used
CurFrom as Variant | A string expression that indicates the base currency, like "USD", "EUR", and so on. The currency name must contain exactly 3 letters. If the parameter is missing, the "USD" is used.
CurTo as Variant | A string expression that indicates the target currency, like "USD", "EUR ", and so on. The currency name must contain exactly 3 letters. If the argument is missing the "EUR" is used.
Double | A numeric expression that indicates the converted value. -1 is returned if the conversion fails. The conversion fails if there are internet, firewall or network problems.

The Currencies property gets the list of available international currencies. For instance by calling the Convert property with no arguments, it returns the exchange rate between USD and EUR. By default, the currently exchange rate is getting from Internet each time when Convert property is called. You can use maps or hash tables in order to optimize how many times the Convert property gets the exchange rate from Internet.

If you want to get the exchange rate between two international currencies in the past, the Date property should be called prior to Convert property as in the following sample:

Dim n As New EXCHANGELibCtl.ExChange
n.Date = "1/1/2001"
MsgBox n.Convert(1, "USD", "XAU")

In the sample, if the Date property is not called the current exchange rate is getting from Internet.


property Currencies

property ExChange.Currencies as String
Gets the list of available currencies.

Type | Description
String | A string expression that contains the list of available currencies. Each line the list represents a currency. Each line contains three letters indicating the short name of the currency followed by a space, and the full name of the currency.

Each time when Currencies property is invoked, the control is getting the list of available currencies over the Internet, so it is recommended to save the list of currencies to a file. The short name must be used by properties like: Convert, Draw. Here's the list of available currencies ( the list contains 171 currencies ):

ADF Andorran Franc
ADP Andorran Peseta
AED Utd. Arab Emir. Dirham
AFA Afghanistan Afghani
ALL Albanian Lek
ANG NL Antillian Guilder
AON Angolan New Kwanza
ARS Argentine Peso
ATS Austrian Schilling
AUD Australian Dollar
AWG Aruban Florin
BBD Barbados Dollar
BDT Bangladeshi Taka
BEF Belgian Franc
BGL Bulgarian Lev
BHD Bahraini Dinar
BIF Burundi Franc
BMD Bermudian Dollar
BND Brunei Dollar
BOB Bolivian Boliviano
BRL Brazilian Real
BSD Bahamian Dollar
BTN Bhutan Ngultrum
BWP Botswana Pula
BZD Belize Dollar
CAD Canadian Dollar
CHF Swiss Franc
CLP Chilean Peso
CNY Chinese Yuan Renminbi
COP Colombian Peso
CFP Central Pacific Franc
CRC Costa Rican Colon
CSK Czech Koruna
CUP Cuban Peso
CVE Cape Verde Escudo
CYP Cyprus Pound
DEM German Mark
DJF Djibouti Franc
DKK Danish Krone
DOP Dominican Peso
DZD Algerian Dinar
ECS Ecuador Sucre
EEK Estonian Kroon
EGP Egyptian Pound
ESP Spanish Peseta
ETB Ethiopian Birr
EUR Euro
FIM Finnish Markka
FJD Fiji Dollar
FKP Falkland Islands Pound
FRF French Franc
GBP United Kingdom Pound
GHC Ghanaian Cedi
GIP Gibraltar Pound
GMD Gambian Dalasi
GNF Guinea Franc
GRD Greek Drachma
GTQ Guatemalan Quetzal
GYD Guyanan Dollar
HKD Hong Kong Dollar
HNL Honduran Lempira
HRK Croatian Kuna
HTG Haitian Gourde
HUF Hungarian Forint
IDR Indonesian Rupiah
IEP Irish Punt
ILS Israeli New Shekel
INR Indian Rupee
IQD Iraqi Dinar
IRR Iranian Rial
ISK Iceland Krona
ITL Italian Lira
JMD Jamaican Dollar
JOD Jordanian Dinar
JPY Japanese Yen
KES Kenyan Shilling
KHR Kampuchean Riel
KHR Cambodian Riel
KMF Comoros Franc
KPW North Korean Won
KRW Korean Won
KWD Kuwaiti Dinar
KYD Cayman Islands Dollar
KZT Kazakhstan Tenge
LAK Lao Kip
LBP Lebanese Pound
LKR Sri Lanka Rupee
LRD Liberian Dollar
LSL Lesotho Loti
LTL Lithuanian Litas
LUF Luxembourg Franc
LVL Latvian Lats
LYD Libyan Dinar
MAD Moroccan Dirham
MGF Malagasy Franc
MMK Myanmar Kyat
MNT Mongolian Tugrik
MOP Macau Pataca
MRO Mauritanian Ouguiya
MTL Maltese Lira
MUR Mauritius Rupee
MVR Maldive Rufiyaa
MWK Malawi Kwacha
MXN Mexican Peso
MYR Malaysian Ringgit
MZM Mozambique Metical
NAD Namibia Dollar
NGN Nigerian Naira
NIO Nicaraguan Cordoba Oro
NLG Dutch Guilder
NOK Norwegian Kroner
NPR Nepalese Rupee
NZD New Zealand Dollar
OMR Omani Rial
PAB Panamanian Balboa
PEN Peruvian Nuevo Sol
PGK Papua New Guinea Kina
PHP Philippine Peso
PKR Pakistan Rupee
PLN Polish Zloty
PTE Portuguese Escudo
PYG Paraguay Guarani
QAR Qatari Rial
ROL Romanian Leu
RUB Russian Rouble
SAR Saudi Riyal
SBD Solomon Islands Dollar
SCR Seychelles Rupee
SDD Sudanese Dinar
SDP Sudanese Pound
SEK Swedish Krona
SGD Singapore Dollar
SHP St. Helena Pound
SIT Slovenian Tolar
SKK Slovak Koruna
SLL Sierra Leone Leone
SOS Somali Shilling
SRG Suriname Guilder
STD Sao Tome/Principe Dobra
SVC El Salvador Colon
SYP Syrian Pound
SZL Swaziland Lilangeni
THB Thai Baht
TND Tunisian Dinar
TOP Tongan Pa'anga
TRL Turkish Lira
TTD Trinidad/Tobago Dollar
TWD Taiwan Dollar
TZS Tanzanian Shilling
UAH Ukraine Hryvnia
UGS Uganda Shilling
USD US Dollar
UYP Uruguayan Peso
VEB Venezuelan Bolivar
VND Vietnamese Dong
VUV Vanuatu Vatu
WST Samoan Tala
XAF CFA Franc BEAC
XAG Silver (oz.)
XAU Gold (oz.)
XCD East Carribean Dollar
XEU ECU
XEU Traded ECU
XOF CFA Franc BCEAO
XPD Palladium (oz.)
XPT Platinum (oz.)
YER Yemen Rial
YUN Yugoslav Dinar
ZAR South African Rand
ZMK Zambian Kwacha
ZWD Zimbabwe Dollar


property Date

property ExChange.Date as Date
Retrieves or sets the conversion date.

Type | Description
Date | A date expression that indicates the conversion date.

Use the Date property before calling Convert property if you are requesting an exchange rate in a given date.


property Debug

property ExChange.Debug (Query as String) as String
Queries a FXP server and gets the results as a string.

Type | Description
Query as String | A string expression that indicates the query being sent to a FXP server.
String | A string expression that indicates the server's response.

Here's the description for the FXP protocol.

Introduction

The Foreign Exchange Protocol (FXP) allows a client to obtain currency exchange rate information from a server over the Internet. The protocol uses an underlying reliable stream protocol, currently TCP/IP.

The server listens for connections to TCP port 5 0 1 1. This port number has not been allocated by any official body, and is subject to change.

A client creates a connection to the server, and sends one or more requests over the connection. Each request is answered by an individual response from the server over the same connection. Requests are always answered in sequence. The connection may be broken by either the client or the server. Responses that are lost due to a broken connection are not re-transmitted.

Requests and responses are transmitted using the ASCII character set. Each request consists of a number of lines of text, followed by a single blank line. Each response consists of a number of lines of header text, followed by a single blank line, optionally followed by a number of lines of data, followed by a single blank line. All lines of text (including blank lines) are terminated by the two character sequence <carriage return> <line feed>. This retains compatibility with the telnet protocol, and telnet can be used to send fxp requests to a server.

The protocol is case insensitive, and requests and responses may be sent in either upper or lower case.

Requests

Each request must begin with a line giving the protocol version used:
fxp/1.1
The protocol version line is followed by one or more request specification lines, in any order. Each request specification line consists of a tag, followed by a single colon character, followed by a single space character, followed by a value. A specific tag may only be used once per request. Values revert to their default values after each request.
  • Query: currencies
    The Query line is optional, and specifies the type of FXP query. The value must be one of quote or currencies. A query type of quote is used to obtain information about the conversion rate between two currencies. A query type of currencies is used to obtain currency symbol codes and currency names. The default value is quote.

  • Quotecurrency: CAD
    If the query type is quote, then the Quotecurrency line is required, and specifies the currency that the client wants to know the price of. The value can be any valid 3 letter ISO or O A N D A currency code.

    If the query type is currencies, then the Quotecurrency line is optional. If present, it specifies the currency symbol that the client wants to know the name of.

  • Quotecurrency: {CHF 125.75}
    Optionally, the Quotecurrency line may be given with a value consisting of a left curly brace character, followed by a 3 letter currency code, followed by a single space character, followed by a floating point number, followed by a right curly brace character. This variant allows the client to specify the amount of the currency to be converted. The default amount is 1.0 units of the currency.

  • Basecurrency: USD
    The Basecurrency line is optional, and is used to specify the currency units used in the response. The value can be any valid 3 letter ISO or O A N D A currency code. The default Basecurrency is USD.

  • Date: Mon, 02 Jun 1997 13:37:56 GMT
    The Date line is optional, and is used to specify the date and time to be used when retrieving the conversion rate information. The value of the date tag must be in the form specified in RFC 822, as modified by RFC 1123. The default Date value is the current date and time.

  • Timeincrement: 86400
    The Timeincrement line is optional, and specifies the number of seconds between adjacent conversion results. The value must be a positive integer. The default Timeincrement value is 60 seconds.

  • Nprices: 12
    The Nprices line is optional, and specifies the number of conversion results required. The value must be a positive integer. If the Nprices value is greater than 1, the specified number of conversions will be performed. The date and time of the first conversion will be given by the Date line. This date and time will be incremented for each subsequent conversion by the amount given on the Timeincrement line. The default Nprices value is 1.

  • Queryid: 129
    The Queryid line is optional. The value of the Queryid tag must be a single token with no embedded space or tab characters. There must be no more than 80 characters in the value. If a Queryid line is present in a request, a Queryid line with the same tag will be included in the response to that request.

  • Quoteperiod: spot
    The Quoteperiod line is optional. It specifies the time period used to collect the data used in the response. A value of day asks for the statistics that best summarize the entire day's prices for the Quotecurrency. A value of spot asks for the statistics that best describe the prices at the specified date and time. The default Quoteperiod value is day.

  • Quotetype: bid ask max_bid
    The Quotetype line is optional. The value of the tag is a non-empty list of tokens, separated by single space characters. The legal tokens are:

    bid | the median price offered by people willing to buy the Quotecurrency
    ask | the median price desired by people willing to sell the Quotecurrency
    min_bid | the minimum bid price
    min_ask | the minimum ask price
    max_bid | the maximum bid price
    max_ask | the maximum ask price
    fractile_low_bid | the price that 75% of the buyers are willing to pay
    fractile_low_ask | the price that 25% of the sellers are willing to accept
    fractile_high_bid | the price that 25% of the buyers are willing to pay
    fractile_high_ask | the price that 75% of the sellers are willing to accept
    num_ticks | the total number of price quotations seen during the Quoteperiod
    date | the date of the data used in composing the response

    The default Quotetype value is bid.

Responses

Each response begins with a line containing the protocol used, followed by a single space character, followed by a three digit status code, optionally followed by text that may be passed to a user explaining the status code:
fxp/1.1 200 ok
The first digit of each response code specifies the class of the response. Response codes starting with 2 specify a successful response, and such responses are followed by lines of data. Response codes starting with 4 indicate an illegal query. Response codes starting with 5 indicate a server error.

Response code | Possible user text explanations
200 | response ok
400 | bad request
404 | not found
500 | server internal error
501 | not implemented
503 | unavailable
505 | version unsupported

The response code line is followed by zero or more response header lines, in any order. Each response header line consists of a tag, followed by a single colon character, followed by a single space character, followed by a value. A specific tag will only be used once per response.

  • Content-lines: 1
    If the response code started with a 2, the response headers will be followed by lines of data. The Content-lines value will be present, and will specify how many lines of data will follow.

  • Queryid: 129
    The Queryid line will be present if it was successfully recognized in the request, regardless of the value of the response code. The value of the Queryid will be equal to the value given in the request.

The request headers will be terminated by a single blank line. If the Content-lines header was present the blank line will be followed by the given number of lines of data, terminated by another blank line.

If the query type was quote, each line of data will contain one value for each token given in the Quotetype line. The values will be separated by single space characters. If the Quotetype token was date, the value will be a date string given in the standard date format specified in RFC 822, as modified by RFC 1123. For all other tokens, if the server can answer the query, the value will be a single floating point number such as:

1.2645
If the server can not answer the query, the value will be the token:
na
for "not available".

If the query type was currencies, each line of data will start with a three letter ISO (or O A N D A) currency symbol, followed by a single space character, followed by the name of the currency in English. If the quotecurrency was specified in the request, the response will contain a single line containing the symbol and name of that currency. If the quotecurrency was not specified, the response will contain multiple lines, one for each of the possible currencies.

http://www.O A N D A.com/products/fxp/protocol.html


property Host

property ExChange.Host as String
Specifies the FXP server.

Type | Description
String | A string expression that indicates the FXP server's address.

Specifies the FXP server address.


property Port

property ExChange.Port as Long
Retrieves or sets the server's port.

Type | Description
Long | A long expression that indicates the FXP's server port.

By default, the Port property is 5 0 1 1.


property Timeout

property ExChange.Timeout as Long
Specifies the amount of time (in seconds) the control will wait for the server response.

Type | Description
Long | A long expression that specifies the amount of time (in seconds) the control will wait for the server response.

By default, the Timeout property is 30 seconds.


ExChart object
Perform currency conversions. The ExChart component display the exchange rates between two international currencies into a given interval. As with any currency converter, it's vitally important that you have the latest exchange rates. That's why ExChange and ExChart get the rates from Internet. Here's the list of supported properties and methods.

Name | Description
Add | Adds data manually.
BackColor | Specifies the chart's background color.
Caption | Specifies the chart's caption
Clear | Clears the data.
Draw | Draws the chart of exchange rates between two international currencies in a given interval.
DrawCurrencies | Draws the currencies.
DrawGridLines | Specifies whether the chart draws the grid lines.
DrawMonths | Draws the months in the chart.
DrawRates | Draws the chart rates.
ForeColor | Specifies the chart's foreground color.
Host | Specifies the FXP server.
Port | Retrieves or sets the server's port.
Timeout | Specifies the amount of time (in seconds) the control will wait for the server response.
Version | Retrieves the control's version.


method Add

method ExChart.Add (Data as Variant)
Adds data manually.

Type | Description
Data as Variant | A double, long expression that indicates the value being added, an array of double or long values that indicates the list of values being added.
Use the Add method to add manually the data to the chart. Use the Draw method to reflect the changes in the chart. Use the Clear method to clear the data in the chart.

The following sample shows how to add manually data to the chart:

With ExChart1
    .Add 10
    .Add 2
    .Add 3.5
    .Add 1.5
    .Add 4
    .Add 4.4
    .Add Array(1, 2, 3, 2, 3, 3, 3.4, 4, 5)
    .Draw
End With


property BackColor

property ExChart.BackColor as Color
Specifies the chart's background color.

Type | Description
Color | A color expression that indicates the control's background color.

Use the BackColor property to specify the control's background color.


property Caption

property ExChart.Caption as String
Specifies the chart's caption

Type | Description
String | A string expression that indicates the chart's title.

Use the Caption property to specify the chart's title. By default, the Caption property is empty, and control displays no caption ( title ).


method Clear

method ExChart.Clear ()
Clears the data.

Type Description
Use the Clear method to clear all values in the chart. Use the Add method to add manually the data to the chart. Use the Draw method to reflect changes in the control.


method Draw

method ExChart.Draw ([From as Variant], [To as Variant], [CurBase as Variant], [CurTarget as Variant], [Reserved as Variant])
Draws the chart of exchange rates between two international currencies in a given interval.

Type | Description
From as Variant | A date expression that indicates the starting date.
To as Variant | A date expression that indicates the ending date.
CurBase as Variant | A string expression that indicates the base currency. The CurBase parameter should be composed by 3 letters, like "USD", "EUR". Check the Currencies property for complete list of currencies.
CurTarget as Variant | A string expression that indicates the target currency. The TargetBase parameter should be composed by 3 letters, like "USD", "EUR". Check the Currencies property for complete list of currencies.
Reserved as Variant | A string expression that indicates the type of query. Reserved for future versions.

The Draw method specifies the coordinates for the chart. If all of the parameter as missing, the control draws the exchange rates between "EUR" and "USD" in the last 45 days. Use the Add method to add data manually.

The following sample draws the chart containing the exchange rates between "USD" and "ROL", in the period "Feb 1, 2001" and "Feb 1 2002":

ExChart1.Draw "2/1/2001", "2/1/2002", "ROL", "USD"


property DrawCurrencies

property ExChart.DrawCurrencies as Boolean
Draws the currencies.

Type | Description
Boolean | A boolean expression that indicates whether the name for the currencies are shown.

Use the DrawCurrencies to hide the name of the currencies represented in the chart, and use Caption property to have your own chart's title.


property DrawGridLines

property ExChart.DrawGridLines as Boolean
Specifies whether the chart draws the grid lines.

Type | Description
Boolean | A boolean expression that indicates whether the control draws the grid lines.

Use the DrawGridLines property to hide the control's grid lines.


property DrawMonths

property ExChart.DrawMonths as Boolean
Draws the months in the chart.

Type | Description
Boolean | A boolean expression that indicates whether the dates are shown in the chart.

Use the DrawMonths to hide the dates in the chart.


property DrawRates

property ExChart.DrawRates as Boolean
Draws the chart rates.

Type | Description
Boolean | A boolean expression that indicates whether the chart contains the exchange rates.

Use the DrawRates property to hide the exchange rates.


property ForeColor

property ExChart.ForeColor as Color
Specifies the chart's foreground color.

Type | Description
Color | A color expression that indicates the control's foreground color.

Use the ForeColor property to specify the control's foreground color.


property Host

property ExChart.Host as String
Specifies the FXP server address.

Type | Description
String | A string expression that indicates the indicates the FXP server's address.

Use the Host property to change the default FXP server.


property Port

property ExChart.Port as Long
Retrieves or sets the server's port.

Type | Description
Long | A long expression that indicates the FXP server's port

A long expression that indicates te FXP server's port. By default, the server's port used is 5 0 1 1.


property Timeout

property ExChart.Timeout as Long
Specifies the amount of time (in seconds) the control will wait for the server response.

Type | Description
Long | A long expression that specifies the amount of time (in seconds) the control will wait for the server response.

By default, the Timeout property is 30 seconds.


property Version

property ExChart.Version as String
Retrieves the control's version.

Type | Description
String | A string expression that indicates the control's version.

Use the Version property to determine the control's version.