>
Formatting with .ToString
 Sub Main()
      Dim d1, d2, d3 As Double
      Dim i1, i2, i3 As Byte
      Dim dec1 As Decimal
      Dim int1 As Integer
      dec1 = 15.27
      int1 = 32000
      d1 = 23.4567
      d2 = 14.01
      d3 = 0.003456
      i1 = 254
      i2 = 37
      i3 = 64
      ' 23.456700 six digit right of decimal point
      Console.WriteLine("F6 " + d1.ToString("F6")) 
      ' 14.0100  four digits right of dec. point      
      Console.WriteLine("F4 " + d2.ToString("F4")) 
      Console.WriteLine("C format " + dec1.ToString("C"))' $15.27      
      Console.WriteLine("D4 " + int1.ToString("D7")) '  0032000
      ' 00000254 leading zeros 8 digits      
      Console.WriteLine("D8 " + i1.ToString("D8"))
      ' four digits hex w/leading zeros      
      Console.WriteLine("X4 " + i2.ToString("X4"))
      ' eight digits hex with leading zeros      
      Console.WriteLine("X8 " + i3.ToString("X8"))
 End Sub
 

This is one way of formatting numbers - using the ToString method with format specifiers Composite formatting, using String.Format is more powerful. See example

10/12/2015
TheLonelyProgrammer.Net
Alone in a sea of non-programmers
Home Composite Formatting ToString Formatting