質問編集履歴

4

コード修正

2023/02/13 08:49

投稿

cerophan
cerophan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -20,9 +20,9 @@
20
20
  ```vbs
21
21
  Dim temp()
22
22
  Set regEx = CreateObject("VBScript.RegExp")
23
+ regEx.Pattern = testPattern
23
24
 
24
25
  For Each test In fso.GetFolder(FolderPath).Files
25
- regEx.Pattern = testPattern
26
26
  If regEx.Test(test.Name) Then
27
27
  ReDim Preserve tmp(1 To i)
28
28
  Set tmp(i) = f

3

コードがまちがってた

2023/02/13 08:46

投稿

cerophan
cerophan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -21,9 +21,9 @@
21
21
  Dim temp()
22
22
  Set regEx = CreateObject("VBScript.RegExp")
23
23
 
24
- For Each f In fso.GetFolder(FolderPath).Files
24
+ For Each test In fso.GetFolder(FolderPath).Files
25
25
  regEx.Pattern = testPattern
26
- If regEx.Test(testName) Then
26
+ If regEx.Test(test.Name) Then
27
27
  ReDim Preserve tmp(1 To i)
28
28
  Set tmp(i) = f
29
29
  i = i + 1

2

インデントがおかしい

2023/02/13 08:44

投稿

cerophan
cerophan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -19,16 +19,15 @@
19
19
 
20
20
  ```vbs
21
21
  Dim temp()
22
+ Set regEx = CreateObject("VBScript.RegExp")
22
23
 
23
24
  For Each f In fso.GetFolder(FolderPath).Files
24
- Set regEx = CreateObject("VBScript.RegExp")
25
- regEx.Pattern = testPattern
25
+ regEx.Pattern = testPattern
26
-
27
- If regEx.Test(testName) Then
26
+ If regEx.Test(testName) Then
28
- ReDim Preserve tmp(1 To i)
27
+ ReDim Preserve tmp(1 To i)
29
- Set tmp(i) = f
28
+ Set tmp(i) = f
30
- i = i + 1
29
+ i = i + 1
31
- End If
30
+ End If
32
31
  Next
33
32
  ```
34
33
 

1

スペルミス

2023/02/13 08:41

投稿

cerophan
cerophan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,7 @@
1
1
  ### 実現したいこと
2
2
 
3
3
  VBAで動いていたコードをVBSに移行するのに悩んでいます。
4
- 下記のコード、Likeが使えなくてReaExpを利用したところですが
4
+ 下記のコード、Likeが使えなくてRegExpを利用したところですが
5
5
  そもそも下記の「ReDim Preserve tmp(1 To i)の行で
6
6
  コンパイルエラーが出ます
7
7
  具体的には「)がありません」とのこと