VB 一张图中绘制多条实时曲线
以下是我的代码,错误的。请指教。谢谢。 再次补充问题,四个text中分别显示的是实时采集的数据,所以这里我分别用模拟数对其赋值,当form加载的时候即开始产生随机数,然后以时间为横坐标,text中的值分别赋给四个Y,在picture1里同时绘制四个曲线.也可以建立access数据库,然后将数据存入数据库。本人初学VB,指定犯了许多无知的错误,恳请帮助。非常感谢。
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Randomize
Text1.Text = 900 + Rnd * 10
Text2.Text = 900 + Rnd * 15
Text3.Text = 900 + Rnd * 20
Text4.Text = 900 + Rnd * 25
Y1 = Text1.Text
Y2 = Text2.Text
Y3 = Text3.Text
Y4 = Text4.Text
x = x + 1
Picture1.Cls
Line1.Y1 = Val(Text1.Text)
Line1.Y2 = Val(Text2.Text)
Line1.Y3 = Val(Text3.Text)
Line1.Y4 = Val(Text4.Text)
End Sub 展开
代码如下:
Private Sub Command1_Click()
Line1.Y1 = Val(Text1.Text)
Line1.Y2 = Val(Text2.Text)
Line2.Y2 = Val(Text4.Text)
Line2.Y1 = Val(Text3.Text)
Command2.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Command2_Click() '获取随机数
Text1 = Int(Rnd * 2000 + 1)
Text2 = Int(Rnd * 2500 + 1)
Text3 = Int(Rnd * 2000 + 1)
Text4 = Int(Rnd * 2500 + 1)
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Form_Load()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Command1.Enabled = False
End Sub
广告 您可能关注的内容 |