多个对象![]() ![]() ![]() |
代表 ListField 对象集合,这些对象定义了 Microsoft FrontPage 列表内所用的文本域。ListField 对象是一个基类,定义了 Microsoft FrontPage 中不同类型的域使用的公用成员。例如,ListFieldCurrency 和 ListFieldNumber 对象允许您自定义货币和数字信息的显示方式。
使用 Fields.Item(index) 可以返回单个 ListField 对象,其中 index 是列表的名称或其在集合中的位置。下列示例显示活动站点第一个列表中所有域的名称。如果站点不包含列表,则向用户显示一条消息。
使用 Add 方法可以将新 ListField 对象添加到 ListFields 集合中。
Sub ListFields()
'Display the names of fields in the current list
Dim objApp As FrontPage.Application
Dim objField As ListField
Dim strType As String
Set objApp = FrontPage.Application
If Not ActiveWeb.Lists Is Nothing Then
For Each objField In objApp.ActiveWeb.Lists.Item(0).Fields
If strType = "" Then
'Create new string
strType = objField.Name & vbCr
Else
'Add next field name to string
strType = strType & objField.Name & vbCr
End If
Next objField
MsgBox "The names of the fields in this list are: " & _
vbCr & strType
Else
'Otherwise display message to user
MsgBox "The current web contains no lists."
End If
End Sub