Module1.bas
资源名称:VBPLCSC09.rar [点击查看]
上传用户:guilu56566
上传日期:2021-04-07
资源大小:1585k
文件大小:1k
源码类别:
家庭/个人应用
开发平台:
Visual Basic
- Attribute VB_Name = "Module1"
- Public Function CHACKSUM(data As String) As String '求和校检码
- Dim i As Long
- Dim nr As Long
- nr = 0
- For i = 1 To Len(data)
- nr = nr + Asc(Mid(data, i, 1))
- Next
- CHACKSUM = Right(Hex(nr), 2)
- End Function
- Public Function CHANGE(data As String) As String '八进制转换十六进制
- Select Case data
- Case "0"
- CHANGE = "0"
- Case "1"
- CHANGE = "1"
- Case "2"
- CHANGE = "2"
- Case "3"
- CHANGE = "3"
- Case "4"
- CHANGE = "4"
- Case "5"
- CHANGE = "5"
- Case "6"
- CHANGE = "6"
- Case "7"
- CHANGE = "7"
- Case "10"
- CHANGE = "8"
- Case "11"
- CHANGE = "9"
- Case "12"
- CHANGE = "A"
- Case "13"
- CHANGE = "B"
- Case "14"
- CHANGE = "C"
- Case "15"
- CHANGE = "D"
- End Select
- End Function
- Public Function backing(data As String) As String '返回状态指示
- Dim i As Long
- Dim nr As Long
- nr = 0
- For i = 1 To Len(data)
- nr = nr + Asc(Mid(data, i, 1))
- Next
- If nr = 6 Then
- backing = "Right"
- ElseIf nr = 5 Then
- backing = "wrong"
- End If
- End Function
- Public Function address(data As Long) As String 'D地址计算
- address = Hex$(data * 2 + &H1000)
- End Function