文件名称:模拟监控程序(含代码)
文件大小:4KB
文件格式:RAR
更新时间:2013-08-06 17:01:42
vb课程设计
Option Explicit Const Pi = 3.1415926 Public b As Integer Dim p() As Single, q() As Single Private Sub Timer1_Timer() Text1 = Rnd * 201 + 100 '生成随机数 Text2 = Rnd * 101 + 20 b = b + 1 ReDim Preserve p(b) '定义两个一维数组用以保存生成的随机树 ReDim Preserve q(b) p(b) = Val(Text1) q(b) = Val(Text2) Shpblue.Height = Text1 * 7 '改变蓝色控件的高度模拟反应釜内液面变化 Shpblue.Top = 2200 + 5880 - Text1 * 7 If b Mod 50 = 0 And b >= 50 Then '在图片框控件中画出对应的曲线 Picture1.Cls Else Picture1.Line (80 * (b Mod 50 - 1), 3000 - p(b - 1) * 10)-(80 * (b Mod 50), 3000 - p(b) * 10), &HFF Picture1.Line (80 * (b Mod 50 - 1), 3000 - q(b - 1) * 10)-(80 * (b Mod 50), 3000 - q(b) * 10), &HFF0000 End If End Sub Private Sub Text1_Change() Dim a As String * 20, c As String * 20 Open "D:\bjz.txt" For Input As #1 Line Input #1, a Line Input #1, c If Val(Text1.Text) > a Then Label3.Caption = "液位超上限" Else: Label3.Caption = "" End If Close #1 End Sub Private Sub Text2_Change() Dim e As String * 20, f As String * 20 Open "D:\bjz.TXT" For Input As #1 Line Input #1, e Line Input #1, f If Val(Text2.Text) > f Then Label4.Caption = "温度超上限" Else: Label4.Caption = "" End If Close #1 End Sub Private Sub cmd1_Click() Form2.Show '窗体2出现 End Sub Private Sub cmd2_Click() Dim m As Integer Open "d:\data.txt" For Output As #2 '保存数据 Print #2, "时间(s), 温度(℃), 液体(cm)" Close #2 For m = 1 To b Open "D:\data.txt" For Append As #3 Write #3, m, p(m), q(m) Close #3 Next End Sub Private Sub cmd3_Click() End '结束程序 End Sub Private Sub Form_Activate() Circle (3340, 8080), 700, vbBlue, -Pi, -2 * Pi ' Circle (3340, 5880), 700, vbRed, -2 * Pi, -Pi End Sub
【文件预览】:
VB
----bjz.txt(14B)
----Form1.frm(12KB)
----工程1.vbp(657B)
----MSSCCPRJ.SCC(190B)
----Form2.frm(2KB)
----工程1.vbw(106B)