内码(十六进制) |
CA |
B1 |
二进制 |
11001010 |
10110001 |
后5位十进制 |
10 |
17 |
前3位十进制 |
6 |
5 |
加密结果 |
10,6,17,5 |
按照上述规则,小明设计了一个解密的VB程序,功能如下:单击“解密”按钮,程序依次将文本框Text1中的字符提取,进行解密处理,并输出在文本框Text2中,程序效果如图a所示,请回答下列问题
Private Sub Command1_Click()
Const n = 100
Dim s As String, ch As String, nm As String
Dim p As Integer, i As Integer, k As Integer, t As Integer Dim a(1 To n) As Integer
s = Text1.Text p = 0: k = 0
For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
Else
If k Mod 2 = 1 Then
Else
a(k+1) = p
End If
k = k + 1:p = 0
End If
Next i
a(k + 1) = p * 32 + a(k)
For i =
nm = nm + dtoh(a(i))
Next i
Text2.Text = nm
End Sub
Function dtoh(x As Integer) As String Const
st1 = "0123456789ABCDEF"
Do While x > 0
x = x \ 16
Loop
End Function