回答編集履歴

1

配列の確保方法がまずかった

2023/02/13 10:13

投稿

KOZ6.0
KOZ6.0

スコア2721

test CHANGED
@@ -7,8 +7,9 @@
7
7
  ```vb
8
8
  Option Explicit
9
9
  Dim fso, f
10
- Dim tmp(100), count
10
+ Dim tmp(), count
11
11
  Dim i
12
+ Redim tmp(100)
12
13
  Set fso = CreateObject("Scripting.FileSystemObject")
13
14
  count = 0
14
15
  For Each f In fso.GetFolder("C:\").Files
@@ -33,10 +34,10 @@
33
34
  Dim tmp, i
34
35
  Set fso = CreateObject("Scripting.FileSystemObject")
35
36
  Set tmp = CreateObject("Scripting.Dictionary")
36
- i = 1
37
+ i = 0
37
38
  For Each f In fso.GetFolder("C:\").Files
39
+ i = i + 1
38
40
  Set tmp(i) = f
39
- i = i + 1
40
41
  Next
41
42
  For i = 1 To tmp.Count
42
43
  MsgBox tmp(i).Name