Knowledge Base

DOC: DataGrid Object Code Example Does Not Work

Article ID: 201958

Article Last Modified on 10/20/2003


APPLIES TO


This article was previously published under Q201958

SUMMARY

The DataGrid Object code example contains several errors that prevent the sample from working correctly. This article contains the correct code example for the DataGrid Object.

MORE INFORMATION

The DataGrid Object is part of the Microsoft Chart Control, MSChart.ocx. You can search Online Help for "DataGrid Object" and click on the Example hypertext to see the faulty code sample that should demonstrate creating a three-dimensional bar chart.

The following is the correct DataGrid Object code example:
    Private Sub Command1_Click()
       Dim rowLabelCount As Integer
       Dim columnLabelCount As Integer
       Dim rowCount As Integer
       Dim columnCount As Integer
       Dim labelIndex As Integer

       MSChart1.chartType = VtChChartType3dBar
       With MSChart1.DataGrid
          ' Set Chart parameters using methods.
          rowLabelCount = 2
          columnLabelCount = 2
          rowCount = 6
          columnCount = 6
          .SetSize rowLabelCount, columnLabelCount, _
          rowCount, columnCount

          ' Randomly fill in the data.
          .RandomDataFill
          ' Then assign labels to second Level.
          labelIndex = 2
          columnCount = 1
          .ColumnLabel(columnCount, labelIndex) = "Product 1"
          columnCount = 4
          .ColumnLabel(columnCount, labelIndex) = "Product 2"
          rowCount = 1
          .RowLabel(rowCount, labelIndex) = "1994"
          rowCount = 4
          .RowLabel(rowCount, labelIndex) = "1995"
       End With
    End Sub
				

Keywords: kbdocerr kbctrl KB201958