1

I tried to display the temperature. I set the temperature to be a double, when I get a temperature, e.g. 77 F, I really want to display 77.0 but I do not know how to do it? Thanks.

success
  • 75
  • 2
  • 11

2 Answers2

0

From: https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-3

Dim value As Double
value = 70
Console.Writeline(value.ToString("0.0", CultureInfo.InvariantCulture))

displays: 70.0

Make sure you search for an answer before posting a question (e.g. "vb.net number format"). I'm surprised the site did not offer you related questions/ answers when you were typing up the question.

RIanGillis
  • 619
  • 1
  • 6
  • 15
0

Use the format specifier F

Dim Temperature As Double
Temperature = 77
Console.WriteLine(Temperature.ToString("F1", CultureInfo.InvariantCulture))

Will display 77.0

See Microsoft documentation

Wei
  • 724
  • 9
  • 10