| 发表于:2007-10-18 09:21:382楼 得分:0 |
option explicit dim bln as boolean const max_value as long = 100 '检测的最大值 const min_value as long = -100 '检测的最小值 const deviceheight as long = max_value - min_value private devicewidth as long '显示宽度由 picturebox1 决定 private xlast as long private ylast as long function getnewvalue() as long static v as long v = v + rnd() * 10 - 5 if v > max_value then v = max_value - (v - max_value) elseif v < min_value then v = min_value + (min_value - v) end if getnewvalue = v end function private sub form_load() with picture1 .borderstyle = vbbsnone devicewidth = .width / screen.twipsperpixelx .height = deviceheight * screen.twipsperpixely .scalemode = vbpixels .backcolor = vbblack .forecolor = vbgreen .autoredraw = true picture1.line (0, max_value)-(devicewidth, max_value), vbyellow end with timer1.interval = 100 end sub private sub command1_click() me.cls end sub private sub timer1_timer() dim x as long dim y as long x = xlast + 1 y = max_value - getnewvalue() if x > = devicewidth then '到达右边界,折回 x = 0 xlast = -1 ylast = y end if picture1.line (x, 0)-(x, deviceheight), vbblack '前一根移动线为黑色 picture1.pset (x, max_value), vbyellow '中黄线 picture1.line (x + 1, 0)-(x + 1, deviceheight), &h8000& '移动线 picture1.line (xlast, ylast)-(x, y) '曲线 xlast = x ylast = y end sub | | |
|