如何用vb画出如图五角星(不用坐标轴)
2个回答
展开全部
(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)、运行,并保存程序。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询