[求助]怎样把十进制数转化成二进制数
SOS小弟不才,请教一下高手,怎样用循环结构实现十进制数转变成二进制数,先在这谢过了.
Option Explicit
Private Sub Command1_Click()
On Error Resume Next
Text1.Text = Dec2Bin(CInt(Text1.Text))
End Sub
Private Function Dec2Bin(i As Integer) As String
Dim temp As Integer
Dim output As String
If i <> 1 Then
temp = i
Do
output = (temp Mod 2) & output
temp = temp \ 2
Loop Until temp = 1
output = (temp Mod 2) & output
Else
output = 1
End If
Dec2Bin = output
End Function