以下のプログラムを実行すると、ランダムな数値が出力される。 Sub BugSample() Dim Arr(1 To 10) As Long Dim UpperBound As Long: Upper = 1000 Dim LowerBound As Long: Lower = 10 Dim i As Integer For i = 1 To 10 Arr(i) = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound) Next Dim j As Integer For j = 1 To 10 Debug.Print Arr(j) Next End Sub …嘘である。 わざとらしいバグなので一見してすぐに気付いた人もいるかもしれないが、これを実行してもイミディエイトウインドウには0が10個並ぶだけである。 バグは変数名である。Uppe
![VBA Debug.Assertの使い方 - t-hom’s diary](https://cdn-ak-scissors.b.st-hatena.com/image/square/b961236ae59b4144bd865979a48bd13c593eaa02/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Ft%2Ft-hom%2F20160114%2F20160114093935.png)