変数宣言

Dim 変数名 As 型名
例えば
Dim a As String
という風に書く。
型名は省略できて
Dim a
と書ける。この場合は型名Variantが省略されたとみなされる。
この型名の省略による“Variantみなしルール”は言語仕様上問題レベルであり、注意が必要です。
例えば
Dim a,b As Integer
と書いてもエラーにはなりません。

一般常識では
Dim a As Integer,b As Integer
と解釈がされるものと勘違いしがちですが、VBAでは
Dim a As Variant,b As Integer
と解釈されてしまいます。両方Integerにしたければきちんと
Dim a As Integer,b As Integer
と書く必要があります。
comments (2)

コメント

hospitablevacuu8.snack.ws | 2017/07/31 04:20 PM
Today, I went to the beach with my children. I found a sea shell and gave it to my 4
year old daughter and said "You can hear the ocean if you put this to your ear."
She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is totally off topic but I had to
tell someone!
How do I stretch my Achilles tendon? | 2017/07/29 05:55 AM
My developer is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the costs. But he's
tryiong none the less. I've been using Movable-type on various websites for about a year and am worried about switching to another platform.
I have heard fantastic things about blogengine.net.
Is there a way I can import all my wordpress content into it?

Any help would be really appreciated!

Comment Form