module1.bas
来自「VB二进制十 六进制之间转换的小程序」· BAS 代码 · 共 28 行
BAS
28 行
Attribute VB_Name = "Module1"
Option Explicit
Public Function DecimalToBinary(DecimalValue As Long, MinimumDigits As Integer) As String
Dim result As String
Dim ExtraDigitsNeeded As Integer
DecimalValue = Abs(DecimalValue)
Do
result = CStr(DecimalValue Mod 2) & result
DecimalValue = DecimalValue \ 2
Loop While DecimalValue > 0
ExtraDigitsNeeded = MinimumDigits - Len(result)
If ExtraDigitsNeeded > 0 Then
result = String(ExtraDigitsNeeded, "0") & result
End If
DecimalToBinary = result
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?