请问怎样用LINE方法怎样编写一个在屏幕上随机产生2条长度宽度和颜色各异的直线段吗?具体程序编码
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 09:58:43
请问怎样用LINE方法怎样编写一个在屏幕上随机产生2条长度宽度和颜色各异的直线段吗?具体程序编码
请问怎样用LINE方法怎样编写一个在屏幕上随机产生2条长度宽度和颜色各异的直线段吗?具体程序编码
请问怎样用LINE方法怎样编写一个在屏幕上随机产生2条长度宽度和颜色各异的直线段吗?具体程序编码
Private Sub Form_Click()
Dim X1 As Long,Y1 As Long,X2 As Long,Y2 As Long
Dim M1 As Long,N1 As Long,M2 As Long,N2 As Long
Dim L1 As Long,L2 As Long
Dim R1 As Integer,G1 As Integer,B1 As Integer
Dim R2 As Integer,G2 As Integer,B2 As Integer
Dim P As Boolean
Cls
Randomize
'Do
X1 = Int(Rnd * Me.Width):Y1 = Int(Rnd * Me.Height)
X2 = Int(Rnd * Me.Width):Y2 = Int(Rnd * Me.Height)
M1 = Int(Rnd * Me.Width):N1 = Int(Rnd * Me.Height)
M2 = Int(Rnd * Me.Width):N2 = Int(Rnd * Me.Height)
' If (X1 M1 Or Y1 N1) And (X2 M2 Or Y2 N2) Then P = True
'Loop While P = True
P = False
Do
L1 = Int(Rnd * 1000) + 4000:L2 = Int(Rnd * 1000) + 4000 '此处的1000和4000可以根据需要去调整,这儿只是为了一种效果,能让你看出来
If L1 L2 Then P = True
Loop Until P = True
P = False
Do
R1 = Int(Rnd * 255):G1 = Int(Rnd * 255):B1 = Int(Rnd * 255)
R2 = Int(Rnd * 255):G2 = Int(Rnd * 255):B2 = Int(Rnd * 255)
If (R1 R2) Or (G1 G2) Or (B1 B2) Then P = True
Loop Until P = True
Me.DrawWidth = 4
Line (X1,Y1)-(X2,Y2),RGB(R1,G1,B1)
Line (M1,N1)-(M2,N2),RGB(R2,G2,B2)
End Sub