作者foolkids (翼をください)
看板Office
标题[算表] 物件阵列在"With"之後变成Empty
时间Mon Aug 22 21:20:03 2016
软体:Office Excel
版本:2010
标题有点难懂,请直接看档案:
https://goo.gl/No20Py (dropbox连结)
巨集内容如下:
Sub AryTest()
Dim ShtAry As Variant
ShtAry = Array(工作表1, 工作表3)
'将工作表设成阵列
MsgBox TypeName(ShtAry(0))
'先传回阵列第一个值的资料型态 = Worksheet
With ShtAry(0)
'经过 with 之後
MsgBox TypeName(ShtAry(0))
'传回阵列第一个值的资料型态 = Empty
.Cells(1, 1) = "Yes"
'但是仍可以继续使用With的物件
End With
With ShtAry(0)
'第二次 with
MsgBox TypeName(ShtAry(0))
.Cells(1, 1) = "Yes*2"
'已无法使用该物件
End With
End Sub
上述状况透过区域变数的监看视窗,确实发现一旦使用了 with 之後,
该阵列内的资料型态就会从 Worksheet 变成 Empty...
请问各位高手,这是什麽原因呢?谢谢!!
--
┌─────────────────────────────┐
│就这样,终於到了启程的日子。
│
│和来机场送行的朋友们说着玩笑话,其实内心恍恍惚惚像在作梦。
│
│也似乎是因为,
为了走到「出发」这一步,耗尽了全部心力。 │
└─────────────────石田裕辅《不去会死!》─┘
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.231.202.252
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Office/M.1471872006.A.CED.html