试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:普通

浙江省临海市白云高级中学2019届高三下学期信息技术3月月考试卷

编写“十六进制加法”程序。程序运行时,在文本框Text1和文本框Text2分别输入两个十六进制数,单击“计算”按钮后在文本框Text3上输出两个十六进制相加后的结果。程序运行如图所示。

(1)、观察代码,触发代码执行的事件名是
(2)、实现上述功能的VB程序如下,请在划线处填入合适的代码。

Private Sub Cmd1_Click()

    Dim a1 As String, a2 As String, sum As String, t As String

    Dim b1 As Integer, b2 As Integer

    Dim dist As Integer, x As Integer, jw As Integer

    a1 = Text1.Text: a2 = Text2.Text: sum = ""

    dist = Len(a1) - Len(a2)

    If dist < 0 Then

        t = a1: a1 = a2: a2 = t

       

    End If

    For i = 1 To dist

        a2 = "0" + a2

    Next i

    jw = 0

    For i =

        If Mid(a1, i, 1) >= "A" And Mid(a1, i, 1) <= "F" Then

            b1 = Asc(a1) - 55

        Else

            b1 = Val(Mid(a1, i, 1))

        End If

        If Mid(a2, i, 1) >= "A" And Mid(a2, i, 1) <= "F" Then

            b2 = Asc(a2) - 55

        Else

            b2 = Val(Mid(a2, i, 1))

        End If

        x = b1 + b2 + jw

        jw = x \ 16

        If Then

            sum = Chr(x Mod 16 + 55) + sum

        Else

            sum = Str(x Mod 16) + sum

        End If

    Next i

   

    Text3.Text = sum

End Sub

(3)、若将代码中加框处代码删除,则图中Text3中显示的结果为
举一反三
返回首页

试题篮