用VB怎么编写利用按钮控件数组来画几何图形(包括直线,矩形,圆等)的程序。
1个回答
展开全部
在窗体上 画3个单项按钮 一个命令按钮 (单项按钮为控件数组)
然后再窗体中添加代码
Dim a As Single, b As Single
Private Sub Command1_Click() '清除按钮
Cls
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
a = X
b = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Option1(0).Value = True Then Me.Line (a, b)-(X, Y) '画直线
If Option1(1).Value = True Then Me.Line (a, b)-(X, Y), , B '画矩形
If Option1(2).Value = True Then Me.Circle (a, b), Sqr((X - a) ^ 2 + (Y - b) ^ 2) '画圆
End Sub
不懂追问
然后再窗体中添加代码
Dim a As Single, b As Single
Private Sub Command1_Click() '清除按钮
Cls
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
a = X
b = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Option1(0).Value = True Then Me.Line (a, b)-(X, Y) '画直线
If Option1(1).Value = True Then Me.Line (a, b)-(X, Y), , B '画矩形
If Option1(2).Value = True Then Me.Circle (a, b), Sqr((X - a) ^ 2 + (Y - b) ^ 2) '画圆
End Sub
不懂追问
追问
请问Option0这里是不是需要建立控件数组?
追答
这段代码 是需要的
其实不需要也可以的 稍微改动下就好
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询