Dim x1 As Single, y1 As Single, s As Integer
Const pi = 3.14159265
Private Sub Form_Load()
Command1.Caption = “圓“
Command2.Caption = “矩形“
Command3.Caption = “三角“
Command4.Caption = “五角“
Command5.Caption = “清“
End Sub
Private Sub Command1_Click()
s = 1
End Sub
Private Sub Command2_Click()
s = 2
End Sub
Private Sub Command3_Click()
s = 3
End Sub
Private Sub Command4_Click()
s = 4
End Sub
Private Sub Command5_Click()
Picture1.Cls
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then x1 = x: y1 = y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = False
Picture1.Refresh
Picture1.PSet (x1, y1)
Select Case s
Case 1
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2)
Case 2
Picture1.Line (x1, y1)-(x, y), , B
Case 3
duobianxing x1, y1, x, y, 3, 60
Case 4
duobianxing x1, y1, x, y, 5, 36
End Select
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = True
Select Case s
Case 1
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2)
Case 2
Picture1.Line (x1, y1)-(x, y), , B
Case 3
duobianxing x1, y1, x, y, 3, 60
Case 4
duobianxing x1, y1, x, y, 5, 36
End Select
End If
End Sub
‘duobianxing函數參數:
‘zhongxinX-多邊形中心的橫坐標
‘zhongxinY-多邊形中心的縱坐標
‘dingdianX-多邊形壹個頂點的橫坐標
‘dingdianY-多邊形壹個頂點的縱坐標
‘bianhuoxing-正多邊形的邊數或者星形的星角數,例如biaohuoxing=5,dingjiao=72則為正五邊形,若dingjiao=36則為五角星(該函數將正多邊形按相鄰頂角點間的折點成直線的特殊星形繪制)