請閱讀以下的模板:如何將兩個腳本合併爲一個?
PID Status LPID
10 Closed 25
11 Open 25
31 Open 31
25 Closed 25
54 Open 31
17 Open 17
20 Closed 31
88 closed 77
77 closed 77
201 open 202
205 open 500
現在,當PID = LPID,即PID被定義爲CPID(子進程ID),否則,它是一個PPID(父進程ID)
現在我!我正在尋找一個代碼,告訴哪個是父代,哪些是子代 - 代表在另一個工作表中標記它們。同時,我想列出所有CPID,同一行中的PPID,如果任何PPID本身具有子流程。輸出將類似於下面
PID Type Of Process? Child List
10 Child
11 Child
31 Parent 54 20
25 Parent 10 11
54 Child
17 Parent
20 Child
88 Child
77 Parent 88
我寫使用VBScript代碼,但實際的片實在是太慢了。對於2500個數據,它需要接近1個小時。所以我想要一個比我的更快的過程。
你能幫助這裏使用VBscript?
代碼1:
Set objExcel1 = CreateObject("Excel.Application")'Object for W2W Report Dump
strPathExcel1 = "D:\VA\CopyofGEWingtoWing_latest_dump_21112012.xls"
objExcel1.Workbooks.open strPathExcel1
Set objSheet1 = objExcel1.ActiveWorkbook.Worksheets(2)
Set objSheet2 = objExcel1.ActiveWorkbook.Worksheets(1)
IntRow1=1
Do While objSheet1.Cells(IntRow1, 1).Value <> ""
IntRow2=4
IntChildListColumn=3
If objSheet1.Cells(IntRow1,2).Value="Parent" Then
Do While objSheet2.Cells(IntRow2, 1).Value <> ""
If objSheet2.Cells(IntRow2,11).Value=objSheet1.Cells(IntRow1,1).Value And objSheet2.Cells(IntRow2,11).Value <> objSheet2.Cells(IntRow2,1).Value Then
objSheet1.Cells(IntRow1,IntChildListColumn).Value=objSheet2.Cells(IntRow2,1).Value
IntChildListColumn=IntChildListColumn+1
End If
IntRow2=IntRow2+1
Loop
End If
IntRow1=IntRow1+1
Loop
代碼2:
EDIT看到兩個ID 201和205具有的子父relationship.But孩子ID,然後將需要存在於輸出列,但父母202和500不應該來輸出列表,因爲有主表中沒有enetry 202 close/open 202
和500 open/close 500
和代碼的響應時間應該是不錯的! – CodeLover
如果你關心性能,那你爲什麼要使用visual basic? –
正如我被要求這樣做!你能幫我嗎? – CodeLover