Choices Property

Microsoft FrontPage Visual Basic

Choices Property

Returns or sets a String that represents an array of all choices in the current field.

expression.Choices

expression    Required. An expression that returns a ListFieldChoice object.

Example

The following example displays the text for all choices in the field "NewChoiceField." If the field contains no choices, a message is displayed to the user. The field "NewChoiceField" is an object of type ListFieldChoice.

    Sub ViewChoices()
'Displays the choices in the current field

    Dim objApp As FrontPage.Application
    Dim objLstFlds As ListFields
    Dim objFldChoice As ListFieldChoice
    Dim VarChoices As Variant
    Dim strChoice As String
    Dim blnFound As Boolean

    Set objApp = FrontPage.Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    'Reference choice field
    Set objFldChoice = objLstFlds.Item("NewChoiceField")
    blnFound = False
    For Each VarChoice In objFldChoice.Choices
        If strChoice = "" Then
            'if first value in string
            strChoice = VarChoice & vbCr
            'The list contains at least one choice
            blnFound = True
        Else
            'add value to string
            strChoice = strChoice & VarChoice & vbCr
        End If
    Next VarChoice
    If blnFound = True Then
        'Display choices
        MsgBox "The current list contains the following choices: " & _
        vbCr & strChoice
    Else
        'Display message to user
        MsgBox "The current field contains no choices."
    End If

End Sub