2. Other Variable Types
Beside declaring a variable to be of type Integer, you can also have the following numerical variable types:
Tried to create a new spreadsheet for this sample, Call it RowCount. Add the following code:
Dim NumberOfRows As Long
NumberOfRows = Worksheets(1).Rows.Count
MsgBox NumberOfRows
To test out floating point numbers. Add the following code:
Dim FloatingPoint As Single
FloatingPoint = 10 / 3
MsgBox FloatingPoint
Change your code to this:
Dim FloatingPoint As Single
FloatingPoint = WorksheetFunction.Pi
MsgBox FloatingPoint
- As Integer ( -32,768 to 32,767)
- As Long ( -2,147,483,648 to 2,147,483,647)
- As Single (floating point number)
- As Double (Long floating point number )
- As Currency
Dim NumberOfRows As Long
NumberOfRows = Worksheets(1).Rows.Count
MsgBox NumberOfRows
To test out floating point numbers. Add the following code:
Dim FloatingPoint As Single
FloatingPoint = 10 / 3
MsgBox FloatingPoint
Change your code to this:
Dim FloatingPoint As Single
FloatingPoint = WorksheetFunction.Pi
MsgBox FloatingPoint
Comments
Post a Comment