题库 高中信息

题干

小王设计了一个Visual Basic小程序,该程序的功能是将一个二进制数转化为十六进制数。程序运行时,在文本框Text1输入二进制数(由0、1构成的数串),单击“转换”按钮Command1后,在文本框Text2中显示转换结果。程序运行界面如下图所示。

实现上述功能的程序代码如下所示,请在划线处填上合适的代码:
Private Sub Command1_Click()
Dim x As String, y As String,
Dim i As Integer, s As Integer, n As Integer, c As String
Dim q As String, h As String, ans As String
n = Len(Text1.Text)
y = Text1.Text
If n Mod 4 <> 0 Then ________________
For i = 1 To s
y = "0" + y
Next i
For i = 1 To n Step 4
________________________
If h = "0000" Then q = "0"
If h = "0001" Then q = "1"
If h = "0010" Then q = "2"
If h = "0011" Then q = "3"
If h = "0100" Then q = "4"
If h = "0101" Then q = "5"
If h = "0110" Then q = "6"
If h = "0111" Then q = "7"
If h = "1000" Then q = "8"
If h = "1001" Then q = "9"
If h = "1010" Then q = "A"
If h = "1011" Then q = "B"
If h = "1100" Then q = "C"
If h = "1101" Then q = "D"
If h = "1110" Then q = "E"
If h = "1111" Then ___________________ 
ans =_____________________  
Next i
Text2.Text =ans
End Sub
上一题 下一题 0.99难度 填空题 更新时间:2019-11-20 12:46:38

答案(点此获取答案解析)