AddChoice Method

Microsoft FrontPage Visual Basic

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 site. The new choices are SaleOption1, which will appear first in the list, and SaleOption2, which will appear second in the list. The relative positions of the choices are determined by the optional Index argument.

Sub AddChoice()
    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

    'Set a reference to the new field and 
    'add two new choices to the list.
    Set objFldChoice = objLstFlds.Item("NewChoiceField")

    objFldChoice.AddChoice text:="SaleOption1", Index:=1
    objFldChoice.AddChoice text:="SaleOption2", Index:=2

End Sub