Table of contents

LookupTable.Count 属性 (项目)LookupTable.Count Property (Project)

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

获取LookupTable集合中项的数目。只读的Gets the number of items in the LookupTable collection. Read-only Long.


表达式计数expression. Count

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


下面的示例提示用户输入某一资源的名称,然后将该资源分配给没有任何资源的任务。The following example prompts the user for the name of a resource and then assigns that resource to tasks without any resources.

Sub AssignResource() 

 Dim T As Task ' Task object used in For Each loop 
 Dim R As Resource ' Resource object used in For Each loop 
 Dim Rname As String ' Resource name 
 Dim RID As Long ' Resource ID 

 RID = 0 
 RName = InputBox$("Enter the name of a resource: ") 

 For Each R in ActiveProject.Resources 
 If R.Name = RName Then 
 RID = R.ID 
 Exit For 
 End If 
 Next R 

 If RID <> 0 Then 
 ' Assign the resource to tasks without any resources. 
 For Each T In ActiveProject.Tasks 
 If T.Assignments.Count = 0 Then 
 T.Assignments.Add ResourceID:=RID 
 End If 
 Next T 
 MsgBox Prompt:=RName &; " is not a resource in this project.", buttons:=vbExclamation 
 End If 

End Sub
© 2018 Microsoft