用VB怎么编写利用按钮控件数组来画几何图形(包括直线,矩形,圆等)的程序。

2024-12-19 11:17:52
推荐回答(1个)
回答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

不懂追问