ListFields Collection

Microsoft FrontPage Visual Basic

ListFields Collection

Multiple objects ListFields

Represents a collection of ListField objects that define the text fields used within Microsoft FrontPage lists. The ListField object is a base class that defines the common members used by the different types of fields in FrontPage. For example, the ListFieldCurrency and ListFieldNumber objects allow you to customize the way in which currency and numeric information is displayed.

This object is supported only by Web pages or sites that are based on Microsoft SharePoint Services.

Using the ListFields collection

Use Fields .Item (index), where index is either the name of the list or its position within the collection, to return a single ListField object. The following example displays the names of all fields in the first list of the active Web site. If the Web site contains no lists, a message is displayed to the user.

Use the Add method to add a new ListField object to the ListFields collection.

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