回复 5楼 风吹过b
感谢哟
程序代码:
Private Sub Form_Load()
Label1(0).BackColor = vbBlack
Label1(1).BackColor = vbRed
Label1(2).BackColor = vbYellow
Label1(3).BackColor = vbBlue
Label2.BackColor = QBColor(0)
DrawState = False '画图状态标志初始化为False
Picture1.AutoRedraw = True
a = Val(Form1.Text1.Text)
b = Val(Form1.Text2.Text)
Picture1.Scale (0, 300)-(300, 0)
For i = 0 To a * 20 Step 20
For j = 0 To b * 20 Step 20
Picture1.Line (i, 0)-(i, j), vbBlack, BF
Picture1.Line (0, j)-(i, j), vbBlack, BF
Next j
Next i
End Sub
Private Sub Label1_Click(Index As Integer)
Label2.BackColor = Label1(Index).BackColor '在标签2显示颜色
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim m As Single
Dim n As Single
ReDim a(0 To m, 0 To n)
Picture1.AutoRedraw = True
If Button = 1 Then
Picture1.AutoRedraw = True
X = X \ 20 + 1
Y = Y \ 20 + 1
X = X * 20
Y = Y * 20
If Label2.BackColor = vbBlack Then
Picture1.Line (X - 20, Y - 20)-(X, Y), vbBlack, BF
ElseIf Label2.BackColor = vbRed Then
Picture1.Line (X - 20, Y - 20)-(X, Y), vbRed, BF
ElseIf Label2.BackColor = vbYellow Then
Picture1.Line (X - 20, Y - 20)-(X, Y), vbYellow, BF
ElseIf Label2.BackColor = vbBlue Then
Picture1.Line (X - 20, Y - 20)-(X, Y), vbBlue, BF
End If
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim m As Single
Dim n As Single
ReDim a(0 To m, 0 To n)
b = Val(Form1.Text2.Text)
X = X \ 20
Y = Y \ 20
Text1.Text = X & " ," & Y
m = X
n = Y
End Sub
这是我自己写的
下面是我自己的小图形的代码,不过不是在一个程序里写的 在两个程序分开写的
程序代码:
Private Sub Picture1_paint()
Dim r As Single
Dim e As Single
Dim h As Single
Dim g As Single
Dim d As Single
Dim f As Single
r = 250
h = 550
d = 2 * r / 3
Picture1.DrawWidth = 13
Picture1.Scale (-1900, 1900)-(1900, -1900)
For e = h / 2 To h / 2 + r Step 1
c = Sqr(r ^ 2 - (e - h / 2) ^ 2)
Picture1.PSet (c, e)
c = -Sqr(r ^ 2 - (e - h / 2) ^ 2)
Picture1.PSet (c, e)
Next e
For g = d / 2 To r Step 1
f = 4 * h * (g - d) ^ 3 / d ^ 3
Picture1.PSet (g, f)
Next g
For j = -r To -(d / 2) Step 1
i = -((4 * h) / (d ^ 3)) * (j + d) ^ 3
Picture1.PSet (j, i)
Next j
For y = -(r + h / 2) To -h / 2 Step 1
X = Sqr(r ^ 2 - (y + h / 2) ^ 2) - (r + d / 2)
Picture1.PSet (X, y)
Next y
For b = -(r + h / 2) To -h / 2 Step 1
a = -Sqr(r ^ 2 - (b + h / 2) ^ 2) + r + d / 2
Picture1.PSet (a, b)
Next b
End Sub
怎么在我的代码基础上加进去呢