MaxLength Property

       

Returns or sets a Long that represents the maximum length (in characters) of the field. Read/write.

expression.MaxLength

expression   Required. An expression that returns a ListFieldSingleLine object.

Example

The following example adds a new field of type fpFieldSingleLine to the ListFields collection and displays the name of the new field, the list to which it was added, and the maximum length in characters of the new field.

Sub CreateSingleLineField()
'Add new SingleLineField
    Dim objApp As FrontPage.Application
    Dim objLstFlds As ListFields
    Dim objListField As ListFieldSingleLine
    Dim strName As String

    Set objApp = FrontPage.Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    strName = "AlternativeName"
    'Add new field of type fpFieldSingleLine to list
    objLstFlds.Add Name:=strName, Description:="Numeric Total Field", _
                   Fieldtype:=fpFieldSingleLine
    Set objListField = objLstFlds.Item("AlternativeName")
    MsgBox "A new field named " & strName & _
           " was added to the list " & _
           objApp.ActiveWeb.Lists.Item(0).Name &
            _ ". The maximum length of the " & _
           "field is " & objListField.MaxLength & " characters."

End Sub