Поделиться через


How to: Hold Integers in a Variable (Visual Basic)

Integers are whole numbers, including positive, zero, and negative. A variable holds integers if you declare it to be of type Integer. The Integer Data Type (Visual Basic) can hold integers from -2,147,483,648 through 2,147,483,647.

You can also use the Long Data Type (Visual Basic), the Short Data Type (Visual Basic), or the SByte Data Type (Visual Basic) to hold integers. For more information, see Numeric Data Types (Visual Basic).

To hold integers in a variable

  1. Declare the variable with a Dim Statement (Visual Basic).

  2. Follow the variable name with an As clause.

  3. Follow the As keyword with the Integer keyword.

    Dim students As Integer
    

See Also

Reference

Data Type Summary (Visual Basic)

Concepts

Data Types in Visual Basic

Type Characters (Visual Basic)

Other Resources

Elementary Data Types (Visual Basic)