您的位置:程序门 -> vb ->



做一个实时曲线显示


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


做一个实时曲线显示
发表于:2007-10-17 21:20:57 楼主
我现在要做一个温度实时曲线的显示,x轴上时间,y轴是温度,由于小弟从没做过关于曲线的程序,希望高手能写出详细的代码,我慢慢研究,希望大家能不吝赐教!!
发表于:2007-10-17 21:56:341楼 得分:0
http://zhidao.baidu.com/question/19898165.html
参阅上述网址我的答复,有详细代码.
发表于: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

发表于:2007-10-18 09:26:233楼 得分:0
command1_click()要改一下:
private   sub   command1_click()
        me.picture1.cls
        xlast   =   0
        ylast   =   0
end   sub

发表于:2007-10-18 12:30:404楼 得分:0
http://www.wave12.com/web/sigcon.asp?bcate=41&scatename=曲线图&id=151&catename=wschart4.6(dll)


快速检索

最新资讯
热门点击