出大事了!!!net的bug!!!
net吧
全部回复
仅看楼主
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
level 2
蔡翀 楼主
不上图你们不会来的!!!!
加上sleep后,这个小过程能正常执行,不加这个myColor就都一样了!!!
2016年11月17日 16点11分 2
level 2
蔡翀 楼主
而且sleep的时间还得再20毫秒以上,如果1-2ms,则结果大概率还是一样的,时间间隔越长,结果越接近正确!!!沃日,net的bug啊!!!
2016年11月17日 16点11分 3
level 2
蔡翀 楼主
并不是这个原因,但是我还是弄不懂。。。。这可见了鬼了。。。
2016年11月17日 16点11分 5
level 2
蔡翀 楼主
坑爹的随机数。。。。
2016年11月17日 17点11分 7
level 2
蔡翀 楼主
顶上去报复微软
2016年11月24日 06点11分 8
1