求助各位高手,本人在picturebox中画了波形,想要当波形幅值>10的时候用黄色,<-10的时候用蓝色,在-10和10之间用红色。

解决方案 »

  1.   

    pic.line (x1,y1)-(x2,y2),RGB(xx,xx,xx)
      

  2.   

    Option Explicit
        Dim x As Long
        Dim y As Long
    Private Sub Form_Load()
        Picture1.AutoRedraw = True
        Timer1.Interval = 100
        Picture1.BackColor = vbBlack
        Picture1.Scale (0, 50)-(1000, -50)   ' 设定自定义座标系统。
        Picture1.Line (0, 0)-(1000, 0), vbWhite
        Picture1.DrawWidth = 2
    End SubPrivate Sub Timer1_Timer()
        x = x + 1
        Randomize
        y = Int((100 * Rnd) + 1) - 50
        Text1 = y
        If y > 10 Then
            Picture1.PSet (x, y), vbYellow
        ElseIf y >= -10 And y <= 10 Then
            Picture1.PSet (x, y), vbRed
        ElseIf y < -10 Then
            Picture1.PSet (x, y), vbBlue
        End If
    End Sub
      

  3.   

    多谢各位,还像请教zdingyun,上面的代码只是划出了点,我需要的是波形,应该如何画呢?
      

  4.   

    看一下这个:
    SkyDrive: 实时曲线
      

  5.   

    晕,8F 的链接是网页链接,你别‘鼠标右键—→目标另存为……’啊。
    要左键点击进入那个网页去下载。
    文件链接是这个:源代码-实时出线.rar(1.6KB)
      

  6.   

    Option ExplicitPrivate Sub Form_Load()
        Picture1.AutoRedraw = True
        Picture1.BackColor = vbBlack
        Picture1.Scale (0, 20)-(200, -20)
        '用白色画曲线'
        Picture1.ForeColor = vbWhite
        Picture1.Line (0, 0)-(50, 20)
        Picture1.Line -(150, -20)
        Picture1.Line -(200, 0)
        '用 And 模式滤色'
        Picture1.DrawMode = vbMaskPen
        Picture1.Line (0, 10)-(200, 20), vbYellow, BF
        Picture1.Line (0, -10)-(200, -20), vbBlue, BF
        Picture1.Line (0, 10)-(200, -10), vbRed, BF
    End Sub