Working with Numeric Data Types
There are a variety of types used for storing numeric data. In math, numbers can either be whole or fractional. Whole numbers, such as years or ages, can be stored in variables of type Short, Integer, or Long. Numbers with decimal places, such as monetary values or scientific measurements, can be stored in Decimal, Single, or Double variables. The following lines of code demonstrate assigning numbers to the various numeric data types:
Dim SelectedYear As Short = 1999 Dim USPopulation As Integer = 283727132 Dim WorldPopulation As Long = 6132426512 Dim ShoeSize As Single = 1234.5E-2 Dim Temperature As Double = 98.6 Dim CostOfDoingBusiness As Decimal = 59.95D Dim SerialNumber As Decimal = 90125
Notice we included ...
Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.