# How to convert European currencies programmatically by using the Excel MSoEuro component and how to use the Euro Currency Tools add-in

### Summary

This article describes how to use the Convert method of the Microsoft Excel MSoEuro component in Microsoft Visual Studio .NET. You can use this method to convert currencies programmatically to euros or to another euro nation's currency. Also, you can use this method to convert currencies programmatically from euros or from another euro nation's currency. This article also describes how to use the Euro Currency Tools add-in in Microsoft Excel 2000 or a later version of Excel.

### Requirements

The following list includes the software that is required to complete this task:
• Visual Studio .NET 2002 or a later version of Visual Studio
• Excel 2000 or a later version of Excel

### How to install the Euro Currency Tools add-in

1. Start Excel.
3. Click to select the Euro Currency Toolscheck box, and then click OK.

The MSoEuro component provides the Convert method. The Convert method can convert currencies in the following three ways:
• From a euro nation's currency to euros
• From euros to a euro nation's currency
• From one euro nation's currency to another euro nation's currency by using euros as an intermediary
The Convert method returns the converted number as a double variable. The Convert method takes the following five arguments.
``Convert (Value, CurrencyFrom, CurrencyTo, FullPrecision, TriangulationPrecision)``
The five arguments are defined in the following list:
• The Value argument is a double variable. This argument is the number of units of currency that you want to convert.
• The CurrencyFrom argument is a string variable. This argument is the three letter code that indicates the unit of currency that you are converting from.
• The CurrencyTo argument is a string variable. This argument is the three letter code that indicates the unit of currency that you are converting to.
• The FullPrecision argument is a Boolean variable. This argument specifies how to display the returned number. If this argument is set to true, all significant digits from the conversion are displayed. If this argument is set to false, not all significant digits from the conversion are displayed. By default, this argument is set to false.
• The TriangulationPrecision argument is an integer variable and is greater than or equal to 3. When the Convert method of the MSoEuro component converts one euro nation's currency to another euro nation's currency, the Convert method can round the intermediate euro value. This argument specifies how many digits to use when the Convert method rounds the intermediate euro value. If you omit this argument, the Convert method does not round the intermediate euro value.

### Codes for European currencies

The following currency codes are available in the Convert method.
 Country/region Basic unit of currency ISO code Belgium Franc BEF Luxembourg Franc LUF Germany Deutsche Mark DEM Spain Peseta ESP France Franc FRF Ireland Pound IEP Italy Lira ITL Netherlands Guilder NLG Austria Schilling ATS Portugal Escudo PTE Finland Markka FIM Greece Drachma GRD Euro nations Euro EUR

### How to use the MSoEuro component to convert euros programmatically

To use the MSoEuro component to convert euros programmatically, follow these steps:
1. Start Visual Studio.
2. Create a new console application by using Microsoft Visual Basic or by using Microsoft Visual C#.
3. Add a reference to the Microsoft Office Euro Converter Object Library (Msoeuro.dll).
4. Insert the following code into the console application. For a Microsoft Visual C# console application, insert the following code in the static void Main method.
``MsoEuro.Converter objEuro=null;try {       //Use MSOEURO.dll for currency conversion       objEuro=(MsoEuro.Converter) Activator.CreateInstance(Type.GetTypeFromProgID( "MsoEuro.Converter"));//Show DLL versionConsole.WriteLine("msoeuro.dll version : " + objEuro.Version);} catch{//DLL not foundConsole.WriteLine("Please check the Installation of MSOEURO.dll on your PC.");Console.Read();System.Environment.Exit(0);}//Value for currency conversionconst string CurrencyFrom = "EUR";const string CurrencyTo = "ITL";double SourceValue = 1; // 1 Euroconst bool FullPrecision = true;const int TriangulationPrecision = 5;double ResultValue;//Call DLL for currency conversionResultValue =objEuro.get_Convert(SourceValue,CurrencyFrom,CurrencyTo,FullPrecision,TriangulationPrecision);            Console.WriteLine("Result is : " + ResultValue);Console.ReadLine();``
For a Visual Basic .NET console application, insert the following code in the Sub Main method.
``Dim objEuro As MsoEuro.ConverterTry   'Use MSOEURO.dll for Currency conversion   objEuro = CreateObject("MSOEURO.Converter")   'Show DLL version   Console.WriteLine(“msoeuro.dll version : “ & objEuro.Version)Catch ex As Exception   'DLL not found   Console.WriteLine("Please check the Installation of MSOEURO.dll on your PC.")   Console.Read()   EndEnd Try'Default value for Currency conversionConst CurrencyFrom As String = "EUR"Const CurrencyTo As String = "ITL"Dim SourceValue As Decimal = 1 ' 1 EuroConst FullPrecision As Boolean = TrueConst NumDigitsAfterDecimal As Integer = 2Dim ResultValue As Decimal  'Call DLL for Currency conversionResultValue =FormatNumber(objEuro.Convert(SourceValue,CurrencyFrom,CurrencyTo, _                                          FullPrecision), NumDigitsAfterDecimal)Console.WriteLine(“Result is : “ & ResultValue)    Console.Read()``
5. Save and then run the console application.

Note You receive the following output.
``msoeuro.dll version : 1.0.128Result is : 1936,27``