Table of contents
TOC
折叠目录
展开目录

Task.WBSPredecessors 属性 (项目)Task.WBSPredecessors Property (Project)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

获取工作分解结构 (WBS) 代码的前置任务,以列表分隔符分隔。只读的字符串Gets the work breakdown structure (WBS) codes of the task predecessors, separated by the list separator. Read-only String.

语法Syntax

表达式WBSPredecessorsexpression. WBSPredecessors

表达式_一个表示任务对象的变量。_expression A variable that represents a Task object.

示例Example

以下示例要求用户输入任务标识号,然后即可提供其前置任务的更易于识别的 WBS 代码分解形式。The following example queries the user for a task ID and then provides a more user-friendly breakdown of its predecessors' WBS codes.

Sub EnumeratePredecessors() 
 Dim Task As Task 
 Dim PredTasks As Tasks 
 Dim ID As Long 
 Dim Predecessors As String 
 Dim List As String 
 Dim Count As Integer 

 ID = CLng(InputBox$("Enter the ID number of the task you wish to examine:")) 

 Set Task = ActiveProject.Tasks(ID) 
 Set PredTasks = Task.PredecessorTasks 
 Predecessors = Task.WBSPredecessors 
 Count = 1 

 If PredTasks.Count = 0 Then 
 List = "Task " &; Task.UniqueID &; ", " &; Task.Name &; ", has no predecessors." 
 Else 
 List = "Predecessors to task " &; Task.UniqueID &; ", " &; Task.Name &; ":" &; vbCrLf &; vbCrLf 
 Do While InStr(Predecessors, ListSeparator) <> 0 
 List = List &; PredTasks(Count).Name &; ": " &; Mid$(Predecessors, 1, InStr(Predecessors, ListSeparator) - 1) &; vbCrLf 
 Predecessors = Right$(Predecessors, Len(Predecessors) - InStr(Predecessors, ListSeparator)) 
 Count = Count + 1 
 Loop 
 List = List &; PredTasks(Count).Name &; ": " &; Predecessors 
 End If 

 MsgBox List 

 Set PredTasks = Nothing 
 Set Task = Nothing 
End Sub
© 2018 Microsoft