📄 form2.frm
字号:
Interval = 1
Left = 7080
Top = -120
End
Begin MSComDlg.CommonDialog dlgChart
Left = 7440
Top = -120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.OptionButton optdef
BackColor = &H00FFFFFF&
Caption = " Default Settings"
BeginProperty Font
Name = "Arial Narrow"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00800080&
Height = 735
Left = 0
Style = 1 'Graphical
TabIndex = 8
ToolTipText = "Default Settings Of Chart"
Top = 5280
Width = 735
End
Begin VB.CommandButton cmdeffect
BackColor = &H0000FFFF&
Caption = "&Hatched"
BeginProperty Font
Name = "Arial Narrow"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 0
Style = 1 'Graphical
TabIndex = 11
ToolTipText = "Fine Division of Y axis"
Top = 4800
Width = 735
End
Begin VB.CommandButton cmdeffect
BackColor = &H0000FFFF&
Caption = "&Solid"
BeginProperty Font
Name = "Arial Narrow"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 0
Style = 1 'Graphical
TabIndex = 12
ToolTipText = "Solid Background"
Top = 4440
Width = 735
End
Begin VB.CommandButton Command3
BackColor = &H80000018&
Caption = "Auto Rotate"
BeginProperty Font
Name = "Arial Narrow"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 0
Style = 1 'Graphical
TabIndex = 1
ToolTipText = "Auto X Axis Rotation For 3D Charts"
Top = 720
Width = 735
End
Begin VB.PictureBox Picture1
Height = 12030
Left = 840
ScaleHeight = 11970
ScaleWidth = 11835
TabIndex = 20
Top = 0
Width = 11894
Begin MSChart20Lib.MSChart MSChart1
Height = 4725
Left = 0
OleObjectBlob = "Form2.frx":0BAE
TabIndex = 21
Top = 0
Width = 7245
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rptrs As Recordset
Dim dbcls As New dbclass
Dim ii As Double
Dim iii As Integer
Dim e As Double
Dim r As Double
Public chht As Long
Public chwd As Long
Dim chht1 As Long
Dim chwd1 As Long
Private Sub cmdborder_Click(Index As Integer)
optdef.Value = False
With MSChart1.Plot.Backdrop
Select Case Index
Case 0
.Frame.Style = VtFrameStyleThickOuter
' Set style to show a shadow.
Case 1
.Frame.Style = VtFrameStyleNull
' .Shadow.Style = VtShadowStyleDrop
End Select
End With
End Sub
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdch_Click(Index As Integer)
optdef.Value = False
MSChart1.ShowLegend = True
Select Case Index
Case 0
MSChart1.chartType = VtChChartType2dBar
Case 1
MSChart1.chartType = VtChChartType3dBar
Case 2
MSChart1.chartType = VtChChartType2dPie
Case 3
MSChart1.chartType = VtChChartType2dLine
Case 4
MSChart1.chartType = VtChChartType3dLine
Case 5
MSChart1.chartType = VtChChartType3dStep
End Select
End Sub
Private Sub cmdeffect_Click(Index As Integer)
optdef.Value = False
With MSChart1.Plot
Select Case Index
Case 0
' Set the style to solid.
.Wall.Brush.Style = VtBrushStyleHatched
Case 1
.Wall.Brush.Style = VtBrushStyleSolid
End Select
' Set the color to white.
.Wall.Brush.FillColor.Set 255, 255, 255
End With
End Sub
Private Sub cmdrowcol_Click(Index As Integer)
optdef.Value = False
Select Case Index
Case 0
MSChart1.Plot.DataSeriesInRow = True
Case 1
MSChart1.Plot.DataSeriesInRow = False
End Select
End Sub
Private Sub cmdsave_Click()
On Error GoTo saverr
Dim strsavefile As String
With dlgChart ' CommonDialog object
.Filter = "Pictures (*.bmp)|*.bmp"
.DefaultExt = "bmp"
.CancelError = True
.ShowSave
strsavefile = .FileName
If strsavefile = "" Then Exit Sub
End With
MSChart1.EditCopy
SavePicture Clipboard.GetData, strsavefile
Exit Sub
saverr:
MsgBox Err.Description
End Sub
Private Sub cmdshadow_Click(Index As Integer)
optdef.Value = False
With MSChart1.Plot.Backdrop
Select Case Index
Case 0
.Shadow.Style = VtShadowStyleDrop
' Set style to show a shadow.
Case 1
.Shadow.Style = VtShadowStyleNull
End Select
End With
End Sub
Private Sub Command1_Click()
e = MSChart1.Plot.View3d.Elevation
r = MSChart1.Plot.View3d.Rotation
Timer1.Enabled = True
End Sub
Private Sub cmdtips_Click()
Form1.Show
End Sub
Private Sub cmdView_Click()
On Error GoTo vierror
chht = MSChart1.Height
chwd = MSChart1.Width
chht1 = chht
chwd1 = chwd
Clipboard.Clear
MSChart1.EditCopy
graph2.Show
Exit Sub
vierror:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Timer2.Enabled = False
e = MSChart1.Plot.View3d.Elevation
r = MSChart1.Plot.View3d.Rotation
ii = 1
iii = 1
End Sub
Private Sub Command3_Click()
e = MSChart1.Plot.View3d.Elevation
r = MSChart1.Plot.View3d.Rotation
Timer1.Enabled = True
End Sub
Private Sub Form_Activate()
If chht1 > 0 Then
MSChart1.Height = chht1
MSChart1.Width = chwd1
End If
End Sub
Private Sub Form_Load()
Dim dbname1 As Connection
Set dbname1 = dbcls.dbname3
Set rptrs = New Recordset
rptrs.Open "select * from graphdb", dbname1, adOpenStatic, adLockOptimistic
With MSChart1
Set .DataSource = rptrs
.ShowLegend = True
End With
End Sub
' Paste these functions into the Declarations section
' of the Form or Code Module.
Public Function RedFromRGB(ByVal rgb As Long) _
As Integer
' The ampersand after &HFF coerces the number as a
' long, preventing Visual Basic from evaluating the
' number as a negative value. The logical And is
' used to return bit values.
RedFromRGB = &HFF& And rgb
End Function
Public Function GreenFromRGB(ByVal rgb As Long) _
As Integer
' The result of the And operation is divided by
' 256, to return the value of the middle bytes.
' Note the use of the Integer divisor.
GreenFromRGB = (&HFF00& And rgb) \ 256
End Function
Public Function BlueFromRGB(ByVal rgb As Long) _
As Integer
' This function works like the GreenFromRGB above,
' except you don't need the ampersand. The
' number is already a long. The result divided by
' 65536 to obtain the highest bytes.
BlueFromRGB = (&HFF0000 And rgb) \ 65536
End Function
Private Sub Form_Unload(Cancel As Integer)
Clipboard.Clear
End Sub
Private Sub MSChart1_SeriesActivated(Series As _
Integer, MouseFlags As Integer, Cancel As Integer)
On Error GoTo colerr
' The CommonDialog control is named dlgChart.
Dim red, green, blue As Integer
With dlgChart ' CommonDialog object
.CancelError = True
.ShowColor
red = RedFromRGB(.Color)
green = GreenFromRGB(.Color)
blue = BlueFromRGB(.Color)
End With
' NOTE: Only the 2D and 3D line charts use the
' Pen object. All other types use the Brush.
If MSChart1.chartType <> VtChChartType2dLine Or _
MSChart1.chartType <> VtChChartType3dLine Then
MSChart1.Plot.SeriesCollection(Series). _
DataPoints(-1).Brush.FillColor. _
Set red, green, blue
Else
MSChart1.Plot.SeriesCollection(Series).Pen. _
VtColor.Set red, green, blue
End If
Exit Sub
colerr:
MsgBox Err.Description
End Sub
Private Sub optdef_Click()
MSChart1.ToDefaults
MSChart1.ShowLegend = True
End Sub
Private Sub Timer1_Timer()
MSChart1.Plot.View3d.Set r + ii, e
ii = ii + 1
End Sub
Private Sub VScroll1_Change()
Picture1.Top = 0 - VScroll1.Value * 200
If VScroll1.Value = 0 Then
' Picture1.Top = Frame1.Top
End If
End Sub
Private Sub HScroll1_Change()
Picture1.Left = 0 - HScroll1.Value * 400
If HScroll1.Value = 0 Then
Picture1.Left = 840
End If
End Sub
Private Sub Timer2_Timer()
MSChart1.Plot.View3d.Set r, e + iii
iii = iii + 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -