VBA--聲明變量類型的一個陷阱!

Declaring Variable Type
You can declare a variable’s type on a Dim statement, or related declaration statements such as Public.
The following declares Sales to be a double precision floating-point number:
Dim Sales As Double
You can declare more than one variable on a Dim:
Dim SalesData As Double, Index As Integer, StartDate As Date
The following can be a trap:
Dim Col, Row, Sheet As Integer


Many users assume that this declares each variable to be Integer. This is not true. Col and Row are
Variant because they have not been given a type. To declare all three as Integer, the line should be as follows:
Dim Col As Integer, Row As Integer, Sheet As Integer







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章