A fellow teachers, the existing survey, database need to count how many statistics each age, such as minimum 2, 22, number 4, 6, 29 years old, and so on, but the number is not fixed, the next time the survey may appear three 21 years old,
Question 1: how to define the Mydata (I, 0) in the I? Again, now can only count the number of definition, for example, 46, is defined Dim Mydata (46, 0) as a double
Read age to list1, each age have a few read list2, tabulation, can be, is now the added not, or do not match, or index of crossing the line,
Question: how to add dynamic line mark?
The code is as follows:
Private Sub Form_Load ()
Dim CNNLZ As New ADODB. Connection
Dim RSNLZ As New ADODB. You
Dim RSNLZTJ As New ADODB. You
CNNLZ. Open the provider="Microsoft. Ace. The oledb. 12.0; Data source="& amp; App. The Path & amp; "\ dk MDB" & amp; "; The Jet OLEDB: Database Password="
RSNLZ. Open the "select distinct age from archive order by age asc", CNNLZ, 1, 3
Dim i1, i2
For i1=0 To RSNLZ. RecordCount - 1
Label1="the age of the data" & amp; RSNLZ. RecordCount
I2=IIf (IsNull (RSNLZ (" age ")), "", RSNLZ (" age"))
List1. AddItem i2
RSNLZ. MoveNext
If RSNLZTJ. State Then RSNLZTJ. Close
RSNLZTJ. Open the "select * from archive where age='" & amp; List1. List (i1) & amp; "'", CNNLZ, 1, 3
List2. AddItem RSNLZTJ. RecordCount
RSNLZTJ. MoveNext
Next i1
Label2="all age number" & amp; List2. ListCount
'=============================because age number is not fixed, here can't define dynamic Mydata (I, 0), can only be fixed specified 46, is there a way to define dynamic number?
Dim MyData (46, 0) As a Double
Dim y As Integer
For y=0 To List2. ListCount - 1
MyData (y, 0)=List2. List (y)
'============================need to add line mark, here is not on, or index of crossing the line, or do not match, comment out is good, but there is no line mark
'MSChart1. Row=y + 1
MSChart1. RowLabel=List1. List (y)
Next y
With MSChart1
. TitleText="age distribution is demonstrated"
. The Plot. SeriesCollection (1). Pen. Width=1
. The Plot. SeriesCollection (1). Pen. Style=VtPenStyleSolid
. The Plot. The Axis (VtChAxisIdX). ValueScale. Auto=True
. The Plot. The Axis (VtChAxisIdY). ValueScale. Auto=False
'//set the maximum
. The Plot. The Axis (VtChAxisIdX). ValueScale. Maximum=1
. The Plot. The Axis (VtChAxisIdY). ValueScale. Maximum=40
'//set the minimum
. The Plot. The Axis (VtChAxisIdY). ValueScale. Minimum=0
. The Plot. The Axis (VtChAxisIdX). ValueScale. Minimum=0
'//
. The Plot. The Axis (VtChAxisIdX). ValueScale. MajorDivision X=12 'main grid number
. The Plot. The Axis (VtChAxisIdY). ValueScale. MajorDivision Y=10 'main grid number
. The Plot. The Axis (VtChAxisIdX). ValueScale. MinorDivision X=0 'secondary grid number
. The Plot. The Axis (VtChAxisIdY). ValueScale. MinorDivision Y=0 'secondary grid number
. The Plot. The Axis (VtChAxisIdX). AxisGrid. MajorPen. Style=VtPenStyleDotted
. The Plot. The Axis (VtChAxisIdY). AxisGrid. MajorPen. Style=VtPenStyleDotted
End With
MSChart1. Plot. SeriesCollection (1). DataPoints (1). The Brush. The FillColor. Set 255, 0, 0 'red
'MSChart1. Plot. AutoLayout=True
MSChart1. Plot. UniformAxis=False
MSChart1. ChartType=1 'set the graphics to map
MSChart1. ChartData data
=https://bbs.csdn.net/topics/MyData '
End Sub
Thank you teacher