为什么以下代码输出的结果是10,求解释~

Private Sub Command1_Click() m = 2.17 n = Len(Str$(m) + Space(5)) Me!Text1 = n End Sub

倚天杖
浏览 328回答 2
2回答

哔哔one

Private Sub Command1_Click()Dim n As String, h As String, i As Integer, c As Stringn = Trim(Text1.Text)If Not (IsNumeric(n) And Val(n) > 0 And Int(n) = Val(n)) Then '判断n非数字、非正数、非整数情况MsgBox "输入数字符n非正整数,请确认退出!", vbOKOnlyExit SubEnd Ifh = Hex(Val(n)) '将n转换成16进制c = ""For i = 1 To Len(h)c = c & Hex2Bin(Mid(h, i, 1))NextPrint cEnd SubFunction Hex2Bin(ByVal str As String) '自定义函数16进制转换成2进制Select Case UCase(str)Case "0": Hex2Bin = "0000"Case "1": Hex2Bin = "0001"Case "2": Hex2Bin = "0010"Case "3": Hex2Bin = "0011"Case "4": Hex2Bin = "0100"Case "5": Hex2Bin = "0101"Case "6": Hex2Bin = "0110"Case "7": Hex2Bin = "0111"Case "8": Hex2Bin = "1000"Case "9": Hex2Bin = "1001"Case "A": Hex2Bin = "1011"Case "B": Hex2Bin = "1100"Case "C": Hex2Bin = "1101"Case "D": Hex2Bin = "1110"Case "E": Hex2Bin = "1111"End SelectEnd Function

守着星空守着你

n=" 2.17 "注意:2.17前有一个空格,这是str的原因比如:a="1",则str(a)=" 1",会多出一个空格
打开App,查看更多内容
随时随地看视频慕课网APP