【发布时间】:2017-05-25 01:39:01
【问题描述】:
我有多个文件名:
c123we_1014_A1_45333 c123we_1014_A2_45333 c123we_1014_A3_45333我需要的是只获取第三个参数并使用消息框显示它。 我所做的是获取第三个参数并将其写入文本文件。
For Each filelog In FileList
LogFile = Split(filelog, "~")(1)
Set otf = fso.OpenTextFile("C:\Data\" & LogFile, 1)
sFile = Split(LogFile, "_")
CurStep = sFile(3)
FileNameStep = LotId & "_" & "Step"
ScriptPath = Mid(ScriptFolder, 1, Len(ScriptFolder) - 8)
If Not fso.FileExists(ScriptFolder & "\" & FileNameStep & ".txt") Then
Set ctf = fso.CreateTextFile(ScriptFolder & "\" & FileNameStep & ".txt", True)
ctf.Close
End If
Set otf = fso.OpenTextFile(ScriptFolder & "\" & FileNameStep & ".txt", 8)
otf.Writeline "Current - " & CurStep
otf.Close
Next
我的文本文件输出如下:
当前 - A1 电流 - A2 电流 - A3我不知道如何使用消息框显示文本文件的内容。
我也尝试过使用数组而不是将其写入 txt 文件,这比使用 txt 文件更简单。我的代码如下:
For Each filelog In FileList
LogFile = Split(filelog, "~")(1)
Set otf = fso.OpenTextFile("C:\Data\" & LogFile, 1)
l = 0
MsgBox FileList.Count
Do While l < FileList.Count
sFile = Split(LogFile, "_")
CurStep = sFile(4)
array.Add CurStep
l = l + 1
Loop
Next
MsgBox Join(array, vbNewLine)
但出现错误。错误在MsgBox Join() 行:
错误:无效的过程调用或参数
【问题讨论】: