VB语言

本类阅读TOP10

·Visual Basic 安装程序的制作!!
·VB中使用EXCEL输出
·一个简单的MP3播放器
·VB程序实现WindowsXP效果的界面!!
·VB打造超酷个性化菜单(六)
·透明位图
·平铺与拉伸MDI窗口的背景图 ~!~
·对《VB程序实现WindowsXP效果的界面》一文的补遗
·从Windows资源管理器中拖动文件
·VB打造超酷个性化菜单(一)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
7、支持函数

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

最后我们再来看一下几个用来设置图表外观的函数。

   SetChartOptions函数

   该函数用来设置图表类型、大小。

Public Sub SetChartOptions(ByVal iXlChartType As xlChartType, _ ByVal iPlotAreaWidth As Integer, ByVal iPlotAreaHeight As Integer) With oExcelChart .ChartType = iXlChartType If (iPlotAreaHeight > 50) Then .PlotArea.Height = iPlotAreaHeight If (iPlotAreaWidth > 50) Then .PlotArea.Width = iPlotAreaWidth End With End Sub

   该函数的目的是让用户设置一些重要的图表属性。另外,该函数也为开发者示范了如何在必要的时候显露图表属性使得用户可以访问它。本函数允许用户设置图表类型、图形区的高度和宽度,这些属性的默认值已经由SetChartBaseProps() 和SetChartWithDataProps()这两个函数设置过了。

   SetChartTitles函数

   该函数设置图表标题、X-轴和Y-轴标题。

Sub SetChartTitles(strMainTitle, strXAxisTitle, strYAxisTitle) On Error Resume Next With oExcelChart '--- 检查并设置图表标题 If (Not IsNull(strMainTitle) And Trim(strMainTitle) < > "") Then .HasTitle = True .ChartTitle.Caption = strMainTitle .ChartTitle.Font.Name = "Verdana" .ChartTitle.Font.FontStyle = "Bold" .ChartTitle.Font.Size = 14 End If '--- 检查并设置X-轴标题 If (Not IsNull(strXAxisTitle) And Trim(strXAxisTitle) < > "") Then .Axes(xlCategory).HasTitle = True .Axes(xlCategory).AxisTitle.Characters.Text = strXAxisTitle .Axes(xlCategory).AxisTitle.Font.Name = "Verdana" .Axes(xlCategory).AxisTitle.Font.FontStyle = "Bold" .Axes(xlCategory).AxisTitle.Font.Size = 12 End If '--- 检查并设置Y-轴标题 If (Not IsNull(strYAxisTitle) And Trim(strYAxisTitle) < > "") Then .Axes(xlValue).HasTitle = True .Axes(xlValue).AxisTitle.Characters.Text = strYAxisTitle .Axes(xlValue).AxisTitle.Font.Name = "Verdana" .Axes(xlValue).AxisTitle.Font.FontStyle = "Bold" .Axes(xlValue).AxisTitle.Font.Size = 12 '--- 设置Y-轴标题的方向 .Axes(xlValue).AxisTitle.HorizontalAlignment = xlCenter .Axes(xlValue).AxisTitle.VerticalAlignment = xlCenter .Axes(xlValue).AxisTitle.Orientation = xlVertical End If End With End Sub

   我们不再具体介绍该函数和后面几个函数的每行代码。该函数的目的是设置图表的各种标题:通过ChartTitile对象设置主标题,通过Axes对象设置X轴和Y轴的标题。窍门在于要设置好Y-轴标题的方向,这通过设置Aces对象内AxisTitle对象的Orientation属性实现。




相关文章

相关软件