修改时间:2024-07-13 浏览次数:159 类型:月考试卷
程序功能:在文本框Text1中输入1~255十进制待校验数,单击“计算”按钮后,在文本框Text2中显示该数对应的二进制值,并在标签Label1中显示该数的校验位值。
Private Sub Command1_Click()
Dim a As Integer, s As String
Dim n As Integer, t As Integer, v As Integer
n = Val(Text1.Text) ' 输入一个1~255的十进制数
t = 0
s = ""
Do While n > 0
a = n Mod 2
n = n \ 2
t =
s = Str(a) + s ' str(a)将变量a的值转换为字符串
Loop
v =
Text2.Text = s ' 显示对应的二进制数值
Label1.Caption = "校验位值:" + Str(v) ' 显示输出校验位值
End Sub
试题篮