If objFSO.GetFile(tempFolder & "\list2.txt").Size > 0 Then
contents = objFSO.OpenTextFile(tempFolder & "\list2.txt", 1, False).ReadAll
Select Case MsgBox ("Link" & contents & "",vbYesNoCancel+vbExclamation+vbSystemModal,"Wassup?")
这是我的vbs代码。我有list2.txt,我在min3 max8行之间有多行。正如你所看到的,我在我的MsgBox中显示了list.txt。
我的问题是我想在MsgBox中隐藏第二行。我无法删除它,因为我需要它。
那么如何隐藏line2并读取其他行呢?
答案 0 :(得分:0)
您无法隐藏MegBox中的部分文字。您需要输入文件内容的副本,而不是第2行。使用RegExp:
Option Explicit
' a string of 5 lines
Dim s : s = Replace("one two three four five", " ", vbCrLf)
' a RegExp to delete line 2
Dim r : Set r = New RegExp
r.Pattern = "(.+)(\n.+)(\n[\s\S]+)"
' a copy of s without line 2
Dim t : t = r.Replace(s, "$1$3")
WScript.Echo Replace(s, vbCrLf, "\r\n")
WScript.Echo Replace(t, vbCrLf, "\r\n")
WScript.Echo t
MsgBox t
输出:
cscript 42231154.vbs
one\r\ntwo\r\nthree\r\nfour\r\nfive
one\r\nthree\r\nfour\r\nfive
one
three
four
five
(我假设vbCrLf EOLs)
答案 1 :(得分:0)
x = d4[["Sales_2015", "Calls_2016"]].transpose().as_matrix()
y = d4["Sales_2016"].transpose().as_matrix()
答案 2 :(得分:0)
这样的事情:
Dim i
i = 1
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim oFile
Set oFile = objFSO.OpenTextFile(tempFolder & "\list2.txt", 1, False)
Dim contents
If objFSO.GetFile(tempFolder & "\list2.txt").Size > 0 Then
Do
' Collect data for all lines except line 2
' -----------------------------------------
If i <> 2 Then
contents = contents & vbNewLine & oFile.ReadLine
Else
' Skip un required line
' ----------------------
oFile.ReadLine
End If
i = i + 1
Loop Until oFile.AtEndOfStream
End If
MsgBox "Link" & contents & "",vbYesNoCancel+vbExclamation+vbSystemModal,"Wassup?"