十进制转二进制
Public Function DECtoBIN(Dec As Long) As String
DECtoBIN = ""
Do While Dec > 0
DECtoBIN = Dec Mod 2 & DECtoBIN
Dec = Dec \ 2
Loop
End Function
十进制转八进制:
VB自带函数:Oct(num)
十进制转十六进制:
VB自带函数:hex(num)
Public Function Dec2Bin(ByVal num As Long) As String
Do
Dec2Bin = num Mod 2 & Dec2Bin
num = num \ 2
Loop While num <> 0
End Function
private sub Form_Click()
dim n as long
n=inputbox("")
print Dec2Bin(n)
end sub