题型:综合题 题类:常考题 难易度:普通
浙教版高中信息技术基础模块综合检测卷
(A .Command1_Click B .Form_load C .Text1_Click)事件处理过程中添加语句 Text1. Text=“”。
Private Sub Command1_Click( )
Dim s As String, ch As String, sum As Integer
Dim fh As Integer
s= Text1.Text:fh=1:p=0:sum =0
For i= 1 To Len (s)
ch= Mid(s, i, 1)
If ch>="0"And ch <="9" Then
p= ①
Else
sum= ②
p=0
If ch ="—"Then
fh=-1
Elself ch ="+" Then
fh=1
End If
End If
Next i
Labell. Caption= Str(sum)
End Sub
① ②
①将该字符的ASCII码值转化为8位二进制数;
②将后4位二进制数进行按位取反(1变0,0变1);
③将操作②生成的4位二进制数均左移1位(原第1位变为新的第4位);
④原高4位二进制数连接到新的后4位二进制数成为最终加密后字符的内码。
例如:字符“a”经过上述加密运算,可得到字符“m”。
ASCII码值 |
转二进制 |
后四位取反 |
后四位左移 |
拼合 |
转十进制 |
转字符 |
97D |
01100001B |
1110 |
1101 |
01101101B |
109D |
“m” |
程序运行界面如图所示,请改正加框处有误的代码:
Private Sub Command1_Click()
Dim s As String:Dim sl As String:Dim jg As String
Dim n As Integer:Dim x As Integer:Dim i As Integer:Dim j As Integer
Dim a(15)As String
a(0)=“0000”:a(1)=“0001”:a(2)=“0010”:a(3)=“0011”
a(4)=“0100”:a(5)=“0101”:a(6)=“0110”:a(7)=“0111¨
a(8)=“1000”:a(9)=“1001”:a(10)=“1010”:a(11)=“1011¨
a(12)=“1100”:a(13)=“1101”:a(14)“1110”:a(15)=“1111”
jg=“ ”
s=Text1.Text
For i=1 To Len(s)
n=Asc(Mid(s,i,1))
low=n Mod 16
low=15-low ‘执行步骤②
s1=Mid(a(low),2,3)&Mid(a(low),1,1) ‘执行步骤③
For i=l To 4
x=x+Val(Mid(s1,j,1))* ‘⑴{#blank#}1{#/blank#}
Next j
x= *16+x ‘⑵{#blank#}2{#/blank#}
jg=jg&Chr(x)
Next i
Text2.Text=jg
End Sub
试题篮