MonthsShown 属性


返回或设置 Long 类型的值,该值确定 Microsoft FrontPage“报表”视图中显示的月份数。可读写。


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


下列示例提示用户输入希望在报表中查看的月份数,然后将 MonthsShown 属性设置为用户输入的值。子例程“SetMonths”提示用户输入数据,验证输入数据的有效性,将该数据转换为正确的类型,然后将 MonthsShown 属性设置为新值。如果该值的类型不正确,则向用户显示一条错误信息。

Sub SetMonthsShow()
'Modifies the MonthsShown property

   Dim objApp As FrontPage.Application
   Set objApp = FrontPage.Application
   Call SetMonths(objApp)

End Sub

Sub SetMonths(ByRef objApp As Application)
'Sets the number of months to view in Reports view

    Dim varNum As Variant
    Dim lngNum As Long
    'Prompt the user to enter a value
    varNum = InputBox("Enter the number of months you wish to view in the report")
    'Check to see that the value is of the correct type
    If IsNumeric(varNum) Then
       'If it's numeric, convert it to Long
       lngNum = CLng(varNum)
       'Set the MonthsShown value to the new value
       objApp.MonthsShown = lngNum
       'Display the new setting information to the user
       MsgBox "The MonthsShown value was set correctly." &
               _  " The number of months that will be shown is " _
               & lngNum & "."
       'Otherwise, display an error message to the user
       MsgBox "The input value was incorrect", vbCritical
    End If

End Sub