Statistical graphics are often generated when the database programming is performed with VB5. There are many ways to generate, the most
It is simple to use the MSChart control provided by VB5. The specific operation method is as follows:
1. First find "Microsoft Chart Control5.0" item in VB5 "Project" → "Part",
Check and apply, the MSCHART control icon appears in the Tools panel. Select it and in new projects for Form1
Picture of a rectangle in painting, generate MSChart1, that is, a histogram of the default state. Set its columnCount property to 1.
2. Generate an Example.mdb database using Access or VB5 Visual Data Manager, in which
CENT a data sheet for TEMP, contains two fields of "Date" and "Data" and enter some in the table
recording.
3. Generate a Command1 button in Form1, then write the following code:
Private submmand1_click ()
DIM I as integer
Dim Newdyn As Recordset
DIM OpenWS as workspace
Dim OpenDB As Database
Set openws = dbengine.workspaces (0)
Set openb = openws.opendatabase (app.path & "/example.mdb")
Set NetDyn = Opendb.OpenRecordset ("Select * from Temp", DBOPENSNAPSHOT)
Newdyn.movelast
Newdyn.movefirst
If newdyn.recordcount = 0 THEN
"Please enter the data in the database!", Vbcritical
EXIT SUB
END IF
With mschart1
.Titletext = "histogram example"
.Rowcount = newdyn.reordcount
For i = 1 to newdyn.recordcount
.Row = i
.Data = newdyn.fields ("data")
.Rtowlabel = newdyn.fields ("Date")
Newdyn.movenext
Next I
End with
Newdyn.close
4. When running, press the Command1 button to generate a chart.
If you want to generate other types of graphics, modify the properties of MSChart1 can be customized to make a variety of two-dimensional or three-dimensional
chart.