新建工程,在表单上放置MSChart1控件,然后粘贴以下代码:
Private Sub Form_Load()
Dim D(1 To 10, 1 To 2) As Double, i As Integer
Randomize
For i = 1 To 10 '产生随机数
D(i, 1) = 100 * Rnd(1)
D(i, 2) = -100 * Rnd(1)
Next
MSChart1.chartType = VtChChartType2dLine '设定图表类型
MSChart1.ChartData = D
End Sub