# Re: 位元运算，请各位高手帮忙，谢谢

Posted by Honey on November 13, 1998 at 23:16:09:

In Reply to: 位元运算，请各位高手帮忙，谢谢 posted by 谢明宪 on November 13, 1998 at 10:54:26:

提供你一段程式 能帮你将十进位的数转成二进位
在表单中加入Command1 Text1 Text2
Text1中输入十进位整数

Option Explicit

Private Sub Command1_Click()
Text2.Text = ch2bit(Text1.Text)
End Sub

Public Function ch2bit(s As String) As String
Dim i As Long, h As Long
Dim d, u
h = CLng(s)
i = 0
Do While 2 ^ i <= h
u = 2 ^ i
If u And h Then
ch2bit = "1" & ch2bit
Else
ch2bit = "0" & ch2bit
End If
i = i + 1
Loop
End Function

若想一BIT 一BIT传出
我想就只剩下字串的处理问题了
可用MID之类的函式 最后加点遮照就好了

Follow Ups: