求vb随机画圆代码,要求:1按鼠标左键定圆心 2拖动定半径 3圆的颜色随机
1个回答
展开全部
Option Explicit
Private x0 As Single
Private y0 As Single
Private MyStart As Boolean
Private R As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x0 = X
y0 = Y
MyStart = True
Else
MyStart = False
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize
If MyStart Then
R = Sqr((X - x0) ^ 2 + (Y - y0) ^ 2)
Picture1.Circle (x0, y0), R, QBColor(Int(Rnd * 16))
MyStart = False
End If
End Sub
Private x0 As Single
Private y0 As Single
Private MyStart As Boolean
Private R As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x0 = X
y0 = Y
MyStart = True
Else
MyStart = False
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize
If MyStart Then
R = Sqr((X - x0) ^ 2 + (Y - y0) ^ 2)
Picture1.Circle (x0, y0), R, QBColor(Int(Rnd * 16))
MyStart = False
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询