# Re: 怎样把字串"1010101" 转换成数值55Hex ??

Posted by Honey on November 06, 1998 at 23:24:06:

In Reply to: 怎样把字串"1010101" 转换成数值55Hex ?? posted by 杀手 on November 06, 1998 at 19:15:07:

可以参考以下
再Form上摆 Command1 Text1 Text2
在Text1上输入二进位的任何值

Option Explicit

Private Sub Command1_Click()
Dim k As Long, i As Long, h As Long
Dim s, d
k = Len(Text1.Text)
s = Text1.Text
For i = 1 To k
d = Mid(s, i, 1)
h = h + 2 ^ (k - i) * CByte(d)
Next
Text2.Text = Hex(h)
End Sub

Follow Ups: