I have a txt file that displays the following information returned by AutoCAD:
; IAcadToolbar: An AutoCAD toolbar
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00d591b4>
; Count (RO) = 19
; DockStatus (RO) = 4
; FloatingRows = 5
; Height (RO) = AutoCAD: The toolbar is invisible. Please make it visible
; HelpString = "Draw Toolbar\n "
; LargeButtons (RO) = 0
; left = 1310
; Name = "Draw"
; Parent (RO) = #<VLA-OBJECT IAcadToolbars 224a6b04>
; TagString (RO) = "ID_TbDraw"
; top = 646
; Visible = 0
; Width (RO) = AutoCAD: The toolbar is invisible. Please make it visible
; Methods supported:
; AddSeparator (1)
; AddToolbarButton (5)
; Delete ()
; Dock (1)
; Float (3)
; Item (1)
Problem being is that I need to filter it so I am only left with:
; DockStatus (RO) = 4
; left = 1310
; Name = "Draw"
; top = 646
; Visible = 0
They must also remain in the same order:
; DockStatus (RO) = 4
; DockStatus (RO) = 4
always on top followed by ; left = 1310
; left = 1310
and so on, all other information may be discarded.
Dose anybody know how to do this in VB.NET?
Imports System.IO
Imports System.Text
Dim output = New StringBuilder()
' Read the lines from FileName into an array of strings. '
Dim input = File.ReadAllLines(FileName)
For Each line in input
If line.StartsWith("; DockStatus (RO) = ") OrElse
line.StartsWith("; left = ") OrElse
line.StartsWith("; Name = ") OrElse
line.StartsWith("; top = ") OrElse
line.StartsWith("; Visible = ") Then
output.AppendLine(line)
End If
Next
Ok, assuming that you've got a file that you're reading line by line, can't you simply do something like this? (pseudo code only)
string result;
foreach line in linesFromFile
{
if(line.StartsWith("; DockStatus") or
line.StartsWith("; Name = "))
{
result += line;
}
}
What I've presented is not pretty, but might get you started.
我建议将所有值都放在字符串中,然后使用分割器,然后过滤掉所需的值,并对它们进行排序,以便在需要时将它们转换为所需的输出格式
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.