C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Maximum: Each numeric type—Byte, Short, Integer, Long—has a different maximum value. This is the highest value the type can represent.
Here: In this program, we display the maximum values for Byte, Short, Integer and Long types.
VB.NET program that uses number types
Module Module1
Sub Main()
Dim a As Byte = Byte.MaxValue
Dim b As Short = Short.MaxValue
Dim c As Integer = Integer.MaxValue
Dim d As Long = Long.MaxValue
Console.WriteLine(a)
Console.WriteLine(b)
Console.WriteLine(c)
Console.WriteLine(d)
End Sub
End Module
Output
255
32767
2147483647
9223372036854775807
Example: We see the MaxValue of UInteger, ULong and UShort. The maximum of ULong is 20 digits.
VB.NET program that uses unsigned types
Module Module1
Sub Main()
' Demonstrate some unsigned types.
Dim value1 As UInteger = UInteger.MaxValue
Dim value2 As ULong = ULong.MaxValue
Dim value3 As UShort = UShort.MaxValue
Console.WriteLine(value1)
Console.WriteLine(value2)
Console.WriteLine(value3)
End Sub
End Module
Output
4294967295
18446744073709551615
65535
Decimal: The Decimal type contains 16 bytes, making it four times the size of an Integer.
DecimalRandom: The Random class generates unpredictable integers. We optionally specify a minimum and maximum.
RandomTip: The String Class extensively uses Char values. Each String internally contains Chars.
CharChrVal and AscInt32: This method converts a value type into an Int32 type. The Integer in VB.NET is an alias for Int32.
Miles, kilometers: We convert units in miles to kilometers, and the opposite. Many numeric conversions can be done in a similar way.
Miles to KilometersTip: Reusing the Math type leads to clearer code. Implementing mathematical functions is a burden.