回答編集履歴

2

ちょっと修正

2017/12/22 07:29

投稿

ttyp03
ttyp03

スコア16998

test CHANGED
@@ -30,6 +30,8 @@
30
30
 
31
31
  Dim lines As Variant ' 分割した行を格納する変数
32
32
 
33
+ Dim line As String ' 1行分
34
+
33
35
 
34
36
 
35
37
  ' 改行コードで分割
@@ -46,15 +48,15 @@
46
48
 
47
49
  ' 行ごとにループ
48
50
 
49
- For Each Line In lines
51
+ For Each line In lines
50
52
 
51
53
  ' 行の先頭に検索対象文字列があるか
52
54
 
53
- If Left(Line, wordlen) = WORD Then
55
+ If Left(line, wordlen) = WORD Then
54
56
 
55
57
  ' 検索対象文字列以降を抽出
56
58
 
57
- Debug.Print Mid(Line, wordlen + 2)
59
+ Debug.Print Mid(line, wordlen + 2)
58
60
 
59
61
  End If
60
62
 

1

追記

2017/12/22 07:29

投稿

ttyp03
ttyp03

スコア16998

test CHANGED
@@ -13,3 +13,51 @@
13
13
  Mid(Line, Len("Release ") + 1)
14
14
 
15
15
  ```
16
+
17
+
18
+
19
+ 更新された質問の回答です。
20
+
21
+ ReadAllでまとめて変数に保持しているのであれば、改行コード単位で分割してから処理するのが良いと思います。
22
+
23
+
24
+
25
+ ```VBA
26
+
27
+ Const WORD = "Release" ' 検索対象の文字列
28
+
29
+ Dim wordlen As Integer ' 検索対象の文字列の長さ
30
+
31
+ Dim lines As Variant ' 分割した行を格納する変数
32
+
33
+
34
+
35
+ ' 改行コードで分割
36
+
37
+ lines = Split(Alllog4, vbCrLf)
38
+
39
+
40
+
41
+ ' 検索対象の文字列の長さを取得
42
+
43
+ strlen = Len(WORD)
44
+
45
+
46
+
47
+ ' 行ごとにループ
48
+
49
+ For Each Line In lines
50
+
51
+ ' 行の先頭に検索対象文字列があるか
52
+
53
+ If Left(Line, wordlen) = WORD Then
54
+
55
+ ' 検索対象文字列以降を抽出
56
+
57
+ Debug.Print Mid(Line, wordlen + 2)
58
+
59
+ End If
60
+
61
+ Next
62
+
63
+ ```