📄 form0804.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "绘制饼图"
ClientHeight = 3255
ClientLeft = 60
ClientTop = 450
ClientWidth = 5520
LinkTopic = "Form1"
ScaleHeight = 3255
ScaleWidth = 5520
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
Height = 2535
Left = 2760
ScaleHeight = 2475
ScaleWidth = 2355
TabIndex = 6
Top = 360
Width = 2415
End
Begin VB.Frame Frame1
Caption = "输人数"
Height = 2775
Left = 360
TabIndex = 0
Top = 240
Width = 2055
Begin VB.TextBox Text4
Height = 270
Left = 1200
TabIndex = 10
Top = 1800
Width = 615
End
Begin VB.TextBox Text3
Height = 270
Left = 1200
TabIndex = 8
Top = 1320
Width = 615
End
Begin VB.TextBox Text2
Height = 270
Left = 1200
TabIndex = 5
Top = 840
Width = 615
End
Begin VB.CommandButton Command1
Caption = "画饼图"
Height = 375
Left = 480
TabIndex = 4
Top = 2280
Width = 975
End
Begin VB.TextBox Text1
Height = 270
Left = 1200
TabIndex = 1
Top = 360
Width = 615
End
Begin VB.Label Label4
Caption = "不及格"
Height = 255
Left = 240
TabIndex = 9
Top = 1800
Width = 735
End
Begin VB.Label Label3
Caption = "及格"
Height = 255
Left = 240
TabIndex = 7
Top = 1320
Width = 735
End
Begin VB.Label Label2
Caption = "良"
Height = 255
Left = 240
TabIndex = 3
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "优"
Height = 255
Left = 240
TabIndex = 2
Top = 360
Width = 735
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
'单击画饼图按钮
Const PI = 3.1415926
Dim x1 As Single, y1 As Single, z1 As Single, w1 As Single
Dim x As Single, y As Single, z As Single, w As Single
Dim r As Single, MidX As Single, MidY As Single
Dim Sum As Single
Picture1.FillStyle = 0 '设置填充式样
x1 = Val(Text1.Text)
y1 = Val(Text2.Text)
z1 = Val(Text3.Text)
w1 = Val(Text4.Text)
Sum = x1 + y1 + z1 + w1
'计算百分比
x = x1 / Sum
y = y1 / Sum
z = z1 / Sum
w = w1 / Sum
'计算图片框的中心点位置
MidX = Picture1.Width / 2
MidY = Picture1.Height / 2
r = Picture1.Width / 2 - 300
If x <> 0 And y <> 0 And z <> 0 Then
'画四色椭圆
Picture1.FillColor = vbRed
Picture1.Circle (MidX, MidY), r, , -2 * PI, -2 * PI * x, 2 / 3
Picture1.FillColor = vbYellow
Picture1.Circle (MidX, MidY), r, , -2 * PI * x, -2 * PI * (x + y), 2 / 3
Picture1.FillColor = vbBlue
Picture1.Circle (MidX, MidY), r, , -2 * PI * (x + y), -2 * PI * (x + y + z), 2 / 3
Picture1.FillColor = vbGreen
Picture1.Circle (MidX, MidY), r, , -2 * PI * (x + y + z), -2 * PI, 2 / 3
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -