level 2
蔡翀
楼主
Dim random As New Random
Dim g As Graphics
g = PictureBox1.CreateGraphics
Dim myPen As Pen = New Pen(Color.Black)
Dim myBrush As Brush
Dim blackBrush As Brush = New SolidBrush(Color.Black)
Dim myColor As New Color
Dim cnt As Integer
For cnt = 0 To 9
myColor = 得到一种随机色("绿")
myBrush = New SolidBrush(myColor)
g.FillRectangle(myBrush, cnt * 100, 0, 100, 100)
g.DrawRectangle(myPen, cnt * 100, 0, 100, 100)
g.DrawString("r:" & myColor.B, New Font("Times New Roman", "10"), blackBrush, cnt * 100, 10)
g.Flush()
Next
end
直接运行,那么这里面的myColor变量的结果都一样,但如果在循环体内暂停一下(调试时暂停),则能正常运行!
2016年11月17日 16点11分
1
Dim g As Graphics
g = PictureBox1.CreateGraphics
Dim myPen As Pen = New Pen(Color.Black)
Dim myBrush As Brush
Dim blackBrush As Brush = New SolidBrush(Color.Black)
Dim myColor As New Color
Dim cnt As Integer
For cnt = 0 To 9
myColor = 得到一种随机色("绿")
myBrush = New SolidBrush(myColor)
g.FillRectangle(myBrush, cnt * 100, 0, 100, 100)
g.DrawRectangle(myPen, cnt * 100, 0, 100, 100)
g.DrawString("r:" & myColor.B, New Font("Times New Roman", "10"), blackBrush, cnt * 100, 10)
g.Flush()
Next
end
直接运行,那么这里面的myColor变量的结果都一样,但如果在循环体内暂停一下(调试时暂停),则能正常运行!
