首页
/
每日頭條
/
生活
/
vba中intersect為空返回啥
vba中intersect為空返回啥
更新时间:2025-11-25 03:04:43

vba中intersect為空返回啥(定義變量integer和long要注意的問題)1

在學習vba變量的時候,我們知道,integer變量和Long變量都有其範圍。

vba中intersect為空返回啥(定義變量integer和long要注意的問題)2

且先看下面的例子:

vba中intersect為空返回啥(定義變量integer和long要注意的問題)3

定義i為integer變量,對i賦值65535,運行代碼出錯。

出錯原因:integer的範圍是 -32768~32767之間,65535>32767,超過integer變量的範圍了,因此報錯。

如果,我們在處理數據的時候,循環遍曆的最大次數,超過了i(integer變量)的範圍,那麼代碼同樣會報錯,如下例子:

解決方法:

聲明整數型的變量,同一使用Long類型,long的範圍足夠大,幾乎不會出現超過範圍的事情。

而且Long比integer更加高效。将integer改為long,代碼就不會報錯了。

vba中intersect為空返回啥(定義變量integer和long要注意的問題)4

vba中intersect為空返回啥(定義變量integer和long要注意的問題)5

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2025 - www.tftnews.com All Rights Reserved