MaxLength 属性

       

返回或设置 Long 类型的值,该值代表域的最大长度(以字符为单位)。可读写。

expression.MaxLength

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

示例

下列示例将 fpFieldSingleLine 类型的新域添加到 ListFields 集合,并显示新域的名称、它所添加到的列表以及新域的最大长度(以字符数为单位)。

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