Private Sub Command1_Click()
If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2) <> "" And IsNull(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)) = False Then '该表格有数据
With MSChart1
.chartType = VtChChartType2dPie
.ColumnCount = 2
.RowCount = 1
Dim XXX As Double
XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
.TitleText = "饼图示例 完成百分比"
.Column = 1
.Row = 1
.Data = XXX
.ColumnLabel = "完成百分比" & Str(XXX) & "%"
.Column = 2
.Row = 1
.Data = 100 - XXX
.ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
End With
' With MSChart1
' .ChartType = VtChChartType2dPie
' .ColumnCount = 2
' .RowCount = 1
' Dim XXX As Double
' XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
' .TitleText = "饼图示例 完成百分比"
' .Column = 1
' .Row = 1
' .Data = XXX
' .ColumnLabel = "完成百分比" & Str(XXX) & "%"
' .Column = 2
' .Row = 1
' .Data = 100 - XXX
' .ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
' End With
End IfEnd Sub
If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2) <> "" And IsNull(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)) = False Then '该表格有数据
With MSChart1
.chartType = VtChChartType2dPie
.ColumnCount = 2
.RowCount = 1
Dim XXX As Double
XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
.TitleText = "饼图示例 完成百分比"
.Column = 1
.Row = 1
.Data = XXX
.ColumnLabel = "完成百分比" & Str(XXX) & "%"
.Column = 2
.Row = 1
.Data = 100 - XXX
.ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
End With
' With MSChart1
' .ChartType = VtChChartType2dPie
' .ColumnCount = 2
' .RowCount = 1
' Dim XXX As Double
' XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
' .TitleText = "饼图示例 完成百分比"
' .Column = 1
' .Row = 1
' .Data = XXX
' .ColumnLabel = "完成百分比" & Str(XXX) & "%"
' .Column = 2
' .Row = 1
' .Data = 100 - XXX
' .ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
' End With
End IfEnd Sub
-- “MSHFlexGrid1”从何来?
.chartType = VtChChartType2dPie
.ColumnCount = 2
.RowCount = 1
Dim XXX As Double
XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
.TitleText = "饼图示例 完成百分比"
.Column = 1
.Row = 1
.Data = XXX
.ColumnLabel = "完成百分比" & Str(XXX) & "%"
.Column = 2
.Row = 1
.Data = 100 - XXX
.ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
End With
才是显示Mschart比例的部分你可以把XXX=50而不是XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))