AddChoice Method

       

Adds a new choice to the list of available choices for the current field. The field must be of type ListFieldChoice.

expression.AddChoice(text, Index)

expression   Required. An expression that returns a ListFieldChoice object.

text  Required. A String that represents the text that will appear in the drop-down list or beside a radio button.

Index  Optional. A Long that represents the position of the choice within the list of choices.

Example

The following example adds two choices to a choice field named NewChoiceField in the first list of the active web. The new choices are SaleOption, which will appear first in the list, and SaleOption2, which will appear second in the list. The relative positions of the choices is determined by the optional Index argument.

Sub AddChoice()
'Adds choices to the choice field

    Dim objApp As FrontPage.Application
    Dim objLstFlds As listFields
    Dim objFldChoice As ListFieldChoice

    Set objApp = FrontPage.Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    'Reference new field and add to new choices to the list
    Set objFldChoice = objLstFlds.Item("NewChoiceField")
    objFldChoice.AddChoice text:="SaleOption1", Index:=1
    objFldChoice.AddChoice text:="SaleOption2", Index:=2

End Sub