【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《Vb中画五角星方法》,欢迎阅读!
Vb中画五角星方法
(1)、新建一个Visual Basic标准工程,设置窗体的Caption属性为“画五角星”。
(2)、在窗体上添加两个按钮,如图○1所示 (3)、窗体的load事件程序代码如下:
Form1.Width = 10000 Form1.Height = 10000
(4)两个按钮的程序代码如下:
Private Sub Command1_Click()
Dim xa, ya, x1, y1, y2, x3, y3, x4, y4, x5, y5 Scale (-8000, 8000)-(8000, -8000) Const π = 3.141592653 R = 5000
xa = R * Cos(18 * π / 180) ya = R * Sin(18 * π / 180) xb = R * Cos(54 * π / 180) yb = R * Sin(54 * π / 180) x1 = -xa: y1 = ya X2 = xa: y2 = ya x3 = -xb: y3 = -yb x4 = 0: y4 = R x5 = xb: y5 = -yb
Line (x1, y1)-(X2, y2), RGB(255, 0, 0) Line (X2, y2)-(x3, y3), RGB(255, 0, 0) Line (x3, y3)-(x4, y4), RGB(255, 0, 0) Line (x4, y4)-(x5, y5), RGB(255, 0, 0) Line (x5, y5)-(x1, y2), RGB(255, 0, 0) End Sub
Private Sub Command2_Click() Me.Cls End Sub
(4)、运行,并保存程序。(运行结果如图○2)
图○1
图○2
本文来源:https://www.wddqxz.cn/9a47bf67f4ec4afe04a1b0717fd5360cba1a8dff.html