Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert to Euros

Status
Not open for further replies.

Jewel142

ISP
Jun 17, 2009
39
Hi Everyone,

I have a program that I need to convert a dollar amount to Euros. I've done the background calculations computing from dollars to euros. I can get the proper amounts to show up in my listbox items but I'm having a hard time figuring out how to swap the decimals and the commas. This is what I have so far:

invoiceListBox.Items.Add(EURO_ACCESSORIES.ToString.Insert(0, "E") & ("N2").PadLeft(10))

Any suggestions? Thanks!!

Jewel
 
Hi Jewel,

You could use something along the lines of:
Code:
Sub Test()
Dim InVal As String, USD As String, Euro As String, Rate As Double
Rate = 1.2234
InVal = InputBox("Number to convert")
USD = Format(InVal, "$0,000.00")
Euro = Replace(Replace(Replace(Format(InVal * Rate, "€0,000.00"), ",", "#"), ".", ","), "#", ".")
MsgBox USD & "*" & Rate & "=" & Euro
End Sub

Cheers
Paul Edstein
[MS MVP - Word]
 
Jewel, you appear to be using VB.NET, so you probably want to ask your question in forum796. Having said that, here's one .NET approach:
Code:
[blue]    Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat

    nfi.CurrencyDecimalSeparator = ","
    nfi.CurrencyGroupSeparator = "."
    nfi.CurrencySymbol = "€"
    MsgBox(EURO_ACCESSORIES.ToString("C", nfi))[/blue]
 
Thank you so much. I will let you know how I make out. Thanks again and have a great day!

Jewel
 
Yes it did! Thank you so much! Is there a really good reference book out there that you can recommend? I've looked at a couple of them but I'm not sure which one to get.

Thanks again and have a great day!

Jewel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top