vba中字典迴圈時的報錯

2021-10-05 14:41:12 字數 584 閱讀 2896

'本錯誤/問題與字典相關, 因為如果是一般的for i=1 to x 這種迴圈未出現問題.

'同乙個存在於某固定行數的for迴圈體系如果沒跑完不能回到之前並繼續進行同乙個(存在於某固定行數)的迴圈, 否則報錯

'該陣列被固定或暫時鎖定, 英文: this array is fixed or temporarily locked.

'如果是到了另乙個for迴圈體系(不同行數), 雖然迴圈的內容一模一樣, 但是不報錯

option explicit

sub test()

dim d, dk, i

set d = createobject(「scripting.dictionary」)

d(1) = 2: d(2) = 3

'for each dk in d.keys

'goto 100

'next dk

100stop

'for i = 1 to 2

'goto 100

'next i

for each dk in d.keys

'goto 100

next dk

end sub

VBA 中的各種迴圈

利用迴圈和分支語句判斷 b 列數字的符號,將結果填入 c列。原始 如如下 1 for 迴圈和 if 語句,如下 sub sign dim sign as string,i as integer 宣告變數 for i 3 to13 step 1if cells i,b 0 then sign 負數 e...

vba 跳出for迴圈 VBA的基本語句

塊 的形式的vba語句比完整一行的 功能和適用性方面更強。二選一 if 條件表示式 then 條件表示式返回true時要執行的操作和計算 else 條件表示式返回false時要執行的操作和計算 end if 多選一 if 條件表示式 then 條件表示式返回true時要執行的操作和計算 elseif...

vba遍歷字串 迴圈遍歷VBA中的指定工作表

您在問題中顯示的 因以下原因而失敗 assets array pipe mat tables pipe diam tables pipe length tables assets是一種工作表,它是一種object,在為物件賦值時必須使用set set assets array pipe mat ta...