📄 globalvar.bas
字号:
num = indata(50)
If (indata(i) < 10) Then
str3 = str3 & "0" & num
Else
str3 = str3 & num
End If
For i = 51 To 52 Step 1
num = indata(i)
If (indata(i) < 10) Then
str4 = str4 & "0" & num
Else
str4 = str4 & num
End If
Next i
ReDim myremsg.haltdata(0) As Byte '没有数据返回
myremsg.haltdata(0) = 0
myremsg.msginfo = str1 & str2 & str3 & str4
MsgBox myremsg.msginfo
GoTo exitfunction
End If '//登记主机IP抱结束
'//请求所辖终端IP后返回的信息(WD:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
If indata(34) = 22 And indata(35) = &H81 And indata(36) = &H3 And UBound(indata) = 52 Then
For i = 37 To 42 Step 1
num = indata(i)
If (indata(i) < 10) Then
str1 = str1 & "0" & num
Else
str1 = str1 & num
End If
Next i
For i = 43 To 46 Step 1
num = indata(i)
If (indata(i) < 10) Then
str2 = str2 & "0" & num
Else
str2 = str2 & num
End If
Next i
For i = 47 To 49 Step 1
num = indata(i)
If (indata(i) < 10) Then
str3 = str3 & "0" & num & "."
Else
str3 = str3 & num & "."
End If
Next i
num = indata(50)
If (indata(i) < 10) Then
str3 = str3 & "0" & num
Else
str3 = str3 & num
End If
ReDim myremsg.haltdata(0) As Byte '没有数据返回
myremsg.haltdata(0) = 0
myremsg.msginfo = str1 & str2 & str3
' MsgBox myremsg.msginfo
frm_ip.txt_ip = str3
GoTo exitfunction
End If '//请求IP报结束
'//给终端输入电量后返回的信息(WD:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
If indata(34) = 23 And indata(35) = &HC0 And indata(36) = &HA1 And UBound(indata) = 61 Then '//购电数据包开始
'//处理SIM 卡号
For i = 37 To 41 Step 1
num = indata(i)
If (indata(i) < 10) Then
str1 = str1 & "0" & num
Else
str1 = str1 & num
End If
Next i
num = indata(42)
str1 = str1 & num
'//处理表号
For i = 43 To 48 Step 1
num = indata(i)
If (indata(i) < 10) Then
str2 = str2 & "0" & num
Else
str2 = str2 & num
End If
Next i
'//处理电量
For i = 49 To 52 Step 1
num = indata(i)
If (indata(i) < 10) Then
str3 = str3 & "0" & num
Else
str3 = str3 & num
End If
Next i
num = Mid(str3, 1, 6) '去掉字符串前面的0
If Mid(str2, 7, 2) = "0" Then
str3 = num
Else
str3 = num & "." & Mid(str3, 7, 2)
End If
'//处理时间
For i = 53 To 59 Step 1
num = indata(i)
If (indata(i) < 10) Then
str4 = str4 & "0" & num
Else
str4 = str4 & num
End If
Next i
str4 = Format(str4, "mmmm-yy-dd mm:hh:ss")
ReDim myremsg.haltdata(0) As Byte '没有数据返回
myremsg.haltdata(0) = 0
str = str1 & str2 & str3 & str4
myremsg.msginfo = str
' iquestion = MsgBox(str, vbYesNo + vbQuestion, "返回信息")
' If iquestion = vbYes Then
' '//向购电表中加入一条购电记录应该在终端返回本次购电数据后舔加
' strsql = "select * from userpower "
' openrs strsql
' rs.AddNew
' With rs
' .Fields("user_id").Value = frm_buypower.txt_id.Text
' .Fields("user_name").Value = frm_buypower.txt_name.Text
' .Fields("user_sim").Value = frm_buypower.txt_sim.Text
' .Fields("user_biaohao").Value = frm_buypower.txt_biaohao.Text
' .Fields("user_powermoney").Value = frm_buypower.txt_money.Text
' .Fields("user_powerprice").Value = frm_buypower.txt_price.Text
' .Fields("user_hgqbili").Value = frm_buypower.txt_hgqbili.Text
' .Fields("buy_powertime").Value = frm_buypower.txt_time.Text
' .Fields("lea_money").Value = frm_buypower.txt_leamoney.Text
' .Fields("buy_quantity").Value = frm_buypower.txt_quantity.Text
' .Fields("buy_biaoquantity").Value = frm_buypower.txt_biaoquantity.Text
' .UpdateBatch
' End With
' clors
' End If
GoTo exitfunction
End If '//购电数据包结束
'//采集命令发送后返回的信息(WD:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
If indata(34) = 98 And indata(35) = &HC0 And indata(36) = &HA2 And UBound(indata) = 136 Then
'//处理SIM 卡号
For i = 37 To 41 Step 1
num = indata(i)
If (indata(i) < 10) Then
str1 = str1 & "0" & num
Else
str1 = str1 & num
End If
Next i
num = indata(42)
str1 = str1 & num
'//处理表号
For i = 43 To 48 Step 1
num = indata(i)
If (indata(i) < 10) Then
str2 = str2 & "0" & num
Else
str2 = str2 & num
End If
Next i
'//有功总电量
For i = 49 To 52 Step 1
num = indata(i)
If (indata(i) < 10) Then
str3 = str3 & "0" & num
Else
str3 = str3 & num
End If
Next i
'//有功峰电量
For i = 53 To 58 Step 1
num = indata(i)
If (indata(i) < 10) Then
str4 = str4 & "0" & num
Else
str4 = str4 & num
End If
Next i
num = Mid(str4, 1, 6) '去掉字符串前面的0
If Mid(str4, 7, 2) = "00" Then
str4 = num
Else
str4 = num & "." & Mid(str4, 7, 2)
End If
'//有功平电量
For i = 59 To 64 Step 1
num = indata(i)
If (indata(i) < 10) Then
str5 = str5 & "0" & num
Else
str5 = str5 & num
End If
Next i
num = Mid(str5, 1, 6) '去掉字符串前面的0
If Mid(str5, 7, 2) = "00" Then
str5 = num
Else
str5 = num & "." & Mid(str5, 7, 2)
End If
'//有功谷电量
For i = 65 To 70 Step 1
num = indata(i)
If (indata(i) < 10) Then
str6 = str6 & "0" & num
Else
str6 = str6 & num
End If
Next i
num = Mid(str6, 1, 6) '去掉字符串前面的0
If Mid(str6, 7, 2) = "00" Then
str6 = num
Else
str6 = num & "." & Mid(str6, 7, 2)
End If
'//无功总电量
For i = 71 To 76 Step 1
num = indata(i)
If (indata(i) < 10) Then
str7 = str7 & "00" & num
Else
str7 = str7 & num
End If
Next i
num = Mid(str7, 1, 6) '去掉字符串前面的0
If Mid(str7, 7, 2) = "00" Then
str7 = num
Else
str7 = num & "." & Mid(str7, 7, 2)
End If
'//无功峰电量
For i = 77 To 82 Step 1
num = indata(i)
If (indata(i) < 10) Then
str8 = str8 & "0" & num
Else
str8 = str8 & num
End If
Next i
num = Mid(str8, 1, 6) '去掉字符串前面的0
If Mid(str8, 7, 2) = "00" Then
str8 = num
Else
str8 = num & "." & Mid(str8, 7, 2)
End If
'//无功平电量
For i = 83 To 88 Step 1
num = indata(i)
If (indata(i) < 10) Then
str9 = str9 & "0" & num
Else
str9 = str9 & num
End If
Next i
num = Mid(str9, 1, 6) '去掉字符串前面的0
If Mid(str9, 7, 2) = "00" Then
str9 = num
Else
str9 = num & "." & Mid(str9, 7, 2)
End If
'//无功谷电量
For i = 89 To 94 Step 1
num = indata(i)
If (indata(i) < 10) Then
str10 = str10 & "00" & num
Else
str10 = str10 & num
End If
Next i
num = Mid(str10, 1, 6) '去掉字符串前面的0
If Mid(str10, 7, 2) = "00" Then
str10 = num
Else
str10 = num & "." & Mid(str10, 7, 2)
End If
'//剩余电量
For i = 95 To 100 Step 1
num = indata(i)
If (indata(i) < 10) Then
str11 = str11 & "0" & num
Else
str11 = str11 & num
End If
Next i
num = Mid(str11, 1, 6) '去掉字符串前面的0
If Mid(str11, 7, 2) = "00" Then
str11 = num
Else
str11 = num & "." & Mid(str11, 7, 2)
End If
'//累计购电量
For i = 101 To 106 Step 1
num = indata(i)
If (indata(i) < 10) Then
str12 = str12 & "0" & num
Else
str12 = str12 & num
End If
Next i
num = Mid(str12, 1, 6) '去掉字符串前面的0
If Mid(str12, 7, 2) = "0" Then
str12 = num
Else
str12 = num & "." & Mid(str12, 7, 2)
End If
num = Mid(str3, 1, 6) '去掉字符串前面的0
If Mid(str3, 7, 2) = "00" Then
str3 = num
Else
str3 = num & "." & Mid(str3, 7, 2)
End If
'//功率因素 X.XXX(X XX X)
num = indata(107)
str13 = num
If (indata(108) < 10) Then
str13 = str13 & "." & "0" & num
Else
str13 = str13 & "." & num
End If
num = indata(109)
str13 = str13 & num
'//A相电压 XXX.X(XX X X)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -