Choices 属性

       

返回或设置 String 类型的值,该值代表当前选项域中所有选项的数组。可读写。

expression.Choices

expression  必选。返回 ListFieldChoice 对象的表达式。

示例

下列示例显示“NewChoiceField”域中所有选项的文本。如果此域不包含选项,则向用户显示一条消息。域 NewChoiceField 是 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