Err: End Sub
'===============CRC校验子程序===================== Public Function CRC(Brr() As Byte) As Long Dim i As Integer, j As Integer Dim TempVal As Long Dim YWval As Long Dim LSB As Integer
TempVal = &HFFFF&
For i = 0 To UBound(Brr()) TempVal = TempVal Xor Brr(i) For j = 1 To 8
YWval = Int(TempVal / 2) LSB = TempVal Mod 2 If LSB = 1 Then
YWval = YWval Xor &HA001& End If
TempVal = YWval Next j Next i
CRC = TempVal Mod 65536 End Function
扩展的曲线图程序
数据可保存于数据库也可保存于文本文件,各自实现代码不同. 使用TIMER控件定时保存数据代码: Private Sub Timer3_Timer()
If Label5.Caption <> CStr(Time$) Then Label5.Caption = Time$ sum_zj = sum_zj + 1 '校准
If sum_zj >= 60 Then
sum_zj = sum_zj - 60 '每分钟记录一组数据 Adodc1.Recordset.AddNew
Adodc1.Recordset(0) = shiyan_sj(0)
Adodc1.Recordset(1) = Mid(Date$, 3, 2) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2) & \Mid(Time$, 7, 2) '记录time
Adodc1.Recordset(2) = Val(Label3(0).Caption) '记录数据
Adodc1.Recordset(3) = Val(Label3(1).Caption) '记录数据 Adodc1.Recordset.Update End If End If End Sub
只要数据能保存于数据库.曲线图无须保存,通过数据检索画图: Private Sub numChaxun_Click()
Adodc1.ConnectionString = \Source=\
Adodc1.RecordSource = \& \Adodc1.Refresh
zsl = Adodc1.Recordset.RecordCount If zsl > 0 Then
numPrint.Enabled = True
numPrintData.Enabled = True numData.Enabled = True For i = 0 To zsl - 1
quexian(1, i) = Adodc1.Recordset(1) For j = 2 To 9
quexian(j, i) = Adodc1.Recordset(j) Next j
Adodc1.Recordset.MoveNext Next i
Picture2.Height = 6765 Picture1.Visible = False
Text2 = Right(quexian(1, 0), 8)
Text3 = Right(quexian(1, zsl - 1), 8) Text1.SelStart = 8 Text1.SelLength = 2
DataGrid1.Visible = False Adodc1.Visible = False Picture2.Height = 7245 Picture1.Visible = True Picture1.Cls colvb = vbBlue xx = 100 yy = 150 txt = \℃\
wp = xp(colvb, xx, yy, txt) xx = 200 yy = 350 txt = \
wp = xp(colvb, xx, yy, txt) yy = 1350 xx = 200 txt = \
wp = xp(colvb, xx, yy, txt) xx = 200 yy = 2350 txt = \
wp = xp(colvb, xx, yy, txt) yy = 3350 xx = 200 txt = \
wp = xp(colvb, xx, yy, txt) yy = 4350 xx = 200 txt = \
wp = xp(colvb, xx, yy, txt) yy = 5350 xx = 200 txt = \
wp = xp(colvb, xx, yy, txt) xx = 200 yy = 6350 txt = \
wp = xp(colvb, xx, yy, txt) 'Time坐标 colvb = vbRed yy = 6500 xx = 400 txt = \
wp = xp(colvb, xx, yy, txt) xx = 1300 txt = \
wp = xp(colvb, xx, yy, txt) xx = 2200 txt = \
wp = xp(colvb, xx, yy, txt) xx = 3100 txt = \
wp = xp(colvb, xx, yy, txt) xx = 4000 txt = \
wp = xp(colvb, xx, yy, txt) xx = 4900
txt = \
wp = xp(colvb, xx, yy, txt) xx = 5800
txt = \小时\
wp = xp(colvb, xx, yy, txt) xx = 6700 txt = \
wp = xp(colvb, xx, yy, txt) xx = 7600 txt = \
wp = xp(colvb, xx, yy, txt) xx = 8500 txt = \
wp = xp(colvb, xx, yy, txt) xx = 9400 txt = \
wp = xp(colvb, xx, yy, txt) xx = 10300 txt = \
wp = xp(colvb, xx, yy, txt) xx = 11200 txt = \
wp = xp(colvb, xx, yy, txt) '画格
Picture1.DrawWidth = 1 ' = dash Picture1.DrawStyle = 0
Picture1.ForeColor = vbBlue Picture1.DrawStyle = 2 For i = 0 To 12
Picture1.Line (450, 400 + i * 500)-(11300, 400 + i * 500) Next
For i = 0 To 12
Picture1.Line (500 + i * 900, 400)-(500 + i * 900, 6400) Next
Picture1.DrawStyle = 0 For j = 0 To zsl - 2
If Int(j / 30) - j / 30 = 0 Then
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 470, quexian(6, j) * -20 + 6400)-(j * 15 + 530, quexian(6, j) * -20 + 6400), vbGreen ', BF
Picture1.Line (j * 15 + 500, quexian(6, j) * -20 + 6435)-(j * 15 + 500, quexian(6, j) * -20 + 6435), vbGreen ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6435)-(j * 15 + 470, quexian(7, j) * -20 + 6435), vbBlue ', BF
相关推荐: