[VBA]關於陣列的直接賦值
各位大大好,小弟初學vba,想請問陣列要如何直接賦值呢
我試過幾種方法
----------------------------------------------------------------
' 方法一: 失敗
Dim arr(0 To 2) As Integer
A = Array(10, 20, 30)
----------------------------------------------------------------
' 方法二:無法指定至陣列
Dim arr(2)
arr = Array(10, 20, 30)
----------------------------------------------------------------
' 方法三: 成功
Dim arr
arr = Array(10, 20, 30)
我的疑問是
1. 我可以理解Array回傳的是variant型態,可是這樣為什麼方法二也不行呢?
2. 如果一定要使用動態陣列且variant型態,這樣的話會減慢運行的效能嗎?
3. 有什麼方法可以直接將固定儲存格的內容寫進陣列的嗎?例如:
arr = Range("A1:A3").Value 這樣的寫法 (當然這樣寫就失敗了 >.<)
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.239.223.196
※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1485439131.A.3FE.html
※ 編輯: marki (36.239.223.196), 01/26/2017 22:01:22
推
01/27 00:06, , 1F
01/27 00:06, 1F
→
01/27 00:07, , 2F
01/27 00:07, 2F
→
01/27 00:08, , 3F
01/27 00:08, 3F
推
01/27 00:15, , 4F
01/27 00:15, 4F
→
01/27 01:37, , 5F
01/27 01:37, 5F
→
01/27 01:37, , 6F
01/27 01:37, 6F
→
01/27 01:38, , 7F
01/27 01:38, 7F
→
01/27 01:41, , 8F
01/27 01:41, 8F
→
01/27 01:42, , 9F
01/27 01:42, 9F
→
01/27 01:42, , 10F
01/27 01:42, 10F
→
01/27 01:42, , 11F
01/27 01:42, 11F
→
01/27 01:43, , 12F
01/27 01:43, 12F
→
01/27 01:44, , 13F
01/27 01:44, 13F
→
01/27 01:46, , 14F
01/27 01:46, 14F
→
01/27 01:47, , 15F
01/27 01:47, 15F
→
01/27 01:48, , 16F
01/27 01:48, 16F
→
01/27 01:50, , 17F
01/27 01:50, 17F
→
01/27 01:50, , 18F
01/27 01:50, 18F
→
01/27 07:13, , 19F
01/27 07:13, 19F
→
01/27 07:14, , 20F
01/27 07:14, 20F
→
01/27 07:25, , 21F
01/27 07:25, 21F
→
01/27 07:25, , 22F
01/27 07:25, 22F
→
01/27 07:26, , 23F
01/27 07:26, 23F
→
01/27 07:27, , 24F
01/27 07:27, 24F
推
01/27 11:21, , 25F
01/27 11:21, 25F
→
01/27 11:22, , 26F
01/27 11:22, 26F
→
01/27 11:22, , 27F
01/27 11:22, 27F
→
01/27 11:26, , 28F
01/27 11:26, 28F
→
01/27 11:27, , 29F
01/27 11:27, 29F
→
01/27 11:27, , 30F
01/27 11:27, 30F
→
01/27 11:27, , 31F
01/27 11:27, 31F
→
01/27 11:27, , 32F
01/27 11:27, 32F
→
01/27 11:27, , 33F
01/27 11:27, 33F
→
01/27 11:28, , 34F
01/27 11:28, 34F
→
01/27 11:28, , 35F
01/27 11:28, 35F
→
01/27 11:28, , 36F
01/27 11:28, 36F
→
01/27 11:29, , 37F
01/27 11:29, 37F
→
01/27 11:29, , 38F
01/27 11:29, 38F
→
01/27 11:29, , 39F
01/27 11:29, 39F
→
01/27 11:29, , 40F
01/27 11:29, 40F
→
01/27 11:29, , 41F
01/27 11:29, 41F
→
01/27 11:29, , 42F
01/27 11:29, 42F
→
01/27 11:29, , 43F
01/27 11:29, 43F
→
01/27 11:30, , 44F
01/27 11:30, 44F
→
01/27 11:30, , 45F
01/27 11:30, 45F
推
01/27 11:40, , 46F
01/27 11:40, 46F
→
01/27 11:42, , 47F
01/27 11:42, 47F
→
01/27 11:43, , 48F
01/27 11:43, 48F
→
01/27 14:55, , 49F
01/27 14:55, 49F
→
01/27 14:56, , 50F
01/27 14:56, 50F
→
01/27 14:56, , 51F
01/27 14:56, 51F
→
01/27 14:59, , 52F
01/27 14:59, 52F
→
01/27 14:59, , 53F
01/27 14:59, 53F
→
01/27 15:01, , 54F
01/27 15:01, 54F
→
01/27 15:04, , 55F
01/27 15:04, 55F
推
01/27 15:05, , 56F
01/27 15:05, 56F
→
01/27 15:05, , 57F
01/27 15:05, 57F
→
01/27 15:06, , 58F
01/27 15:06, 58F
→
01/28 10:03, , 59F
01/28 10:03, 59F
→
01/28 18:42, , 60F
01/28 18:42, 60F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章