locked
VB console app shows ? instead of € (euro sign) RRS feed

  • Question

  • Hi,

    as a follow-up to this post (not by me) I decided to post this question here

    https://trainingsupport.microsoft.com/en-us/tcmva/forum/tcmvacoursefdbk-tcmvavisual/lesson-13-working-with-strings/475f61cd-f080-40d5-a142-441f9ff4549b

    The problem is as follows: In Visual Studio 2017 I tried to create a console app with the following code. 

    Dim myString = String.Format("{0:C2}", 23.35)
    
            Console.WriteLine(myString)
            Console.ReadLine()

    Since I live in Germany the console window should show me a € (euro sign), but instead it only shows a ?. The region and currency settings in Windows are all correct. I tried switching to $ and it works then.

    What can I do to fix this?

    Edit: The language is Visual Basic. The code is from here: https://mva.microsoft.com/en-us/training-courses/visual-basic-fundamentals-for-absolute-beginners-16507?l=bEVjNPKbC_6806218965


    • Edited by dee7kay Wednesday, July 12, 2017 9:22 AM
    Wednesday, July 12, 2017 9:20 AM

Answers

  •  Console.OutputEncoding = System.Text.Encoding.UTF8
     Dim myString = String.Format("{0:C2}", 23.35)
     Console.WriteLine(myString)
     'I prefer by the way
      Console.WriteLine(23.35.ToString("c2"))
     Console.ReadLine()

    By the way for Les, I've standard "nl-NL", it does not affect the console presentation which is probably in ANSI (An old MS Dos format)


    Success
    Cor

    • Proposed as answer by Reed KimbleMVP Wednesday, July 12, 2017 2:38 PM
    • Marked as answer by dee7kay Thursday, July 13, 2017 6:41 AM
    Wednesday, July 12, 2017 10:28 AM

All replies

  • Hi

    Maybe this?

     Dim cult As New Globalization.CultureInfo("de-DE")
     Console.WriteLine(1234.56.ToString("c", cult))


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, July 12, 2017 10:26 AM
    • Proposed as answer by Reed KimbleMVP Wednesday, July 12, 2017 2:38 PM
    Wednesday, July 12, 2017 10:03 AM
  •  Console.OutputEncoding = System.Text.Encoding.UTF8
     Dim myString = String.Format("{0:C2}", 23.35)
     Console.WriteLine(myString)
     'I prefer by the way
      Console.WriteLine(23.35.ToString("c2"))
     Console.ReadLine()

    By the way for Les, I've standard "nl-NL", it does not affect the console presentation which is probably in ANSI (An old MS Dos format)


    Success
    Cor

    • Proposed as answer by Reed KimbleMVP Wednesday, July 12, 2017 2:38 PM
    • Marked as answer by dee7kay Thursday, July 13, 2017 6:41 AM
    Wednesday, July 12, 2017 10:28 AM
  •  Console.OutputEncoding = System.Text.Encoding.UTF8
     Dim myString = String.Format("{0:C2}", 23.35)
     Console.WriteLine(myString)
     'I prefer by the way
      Console.WriteLine(23.35.ToString("c2"))
     Console.ReadLine()

    By the way for Les, I've standard "nl-NL", it does not affect the console presentation which is probably in ANSI (An old MS Dos format)


    Success
    Cor

    Hi

    The code I posted results in      1.234,56 €

    is that as it should be? I'm not familiar with the protocol over there.


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, July 12, 2017 10:49 AM
    Wednesday, July 12, 2017 10:48 AM
  • Yea that is in Germany, in the EURO zone is the currencysign still on the same place as in past. 

    So in Holland  € 1.234,6  was ƒ 1.234,56

    and in Germany 1.234,56 € was 1.234,56 DM

    But that is all done by the settings of the culture settings of the OS.


    Success
    Cor

    Wednesday, July 12, 2017 11:18 AM

  • But that is all done by the settings of the culture settings of the OS.


    Success
    Cor

    Hi

    Yes, the culture settings are correct - just that I thought from your earlier post that something was incorrect in the output. No problem.


    Regards Les, Livingston, Scotland

    Wednesday, July 12, 2017 11:29 AM
  • Hi

    Maybe this?

     Dim cult As New Globalization.CultureInfo("de-DE")
     Console.WriteLine(1234.56.ToString("c", cult))


    Regards Les, Livingston, Scotland



    Strangely, this doesn't work for me. I still get a ? as output.

    Anyway, thank you very much for posting :)

    Thursday, July 13, 2017 6:48 AM
  •  Console.OutputEncoding = System.Text.Encoding.UTF8
     Dim myString = String.Format("{0:C2}", 23.35)
     Console.WriteLine(myString)
     'I prefer by the way
      Console.WriteLine(23.35.ToString("c2"))
     Console.ReadLine()

    By the way for Les, I've standard "nl-NL", it does not affect the console presentation which is probably in ANSI (An old MS Dos format)


    Success
    Cor


    This works just fine. Thank you very much :)
    Thursday, July 13, 2017 6:49 AM