O'Reilly logo

Special Edition Using Microsoft® Visual Basic® .NET by Jeff Spotts, Brian Siler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required