VB string 转 byte
我打开一个文件,然后读取到byte里,然后直接复制到string(不是普通的转换,比如byte的值是“01000100",string的值也要是"01000100"),经...
我打开一个文件,然后读取到byte里,然后直接复制到string(不是普通的转换,比如byte的值是“01000100",string的值也要是"01000100"),经过处理后再复制到Byte写入文件.怎么实现?
展开
1个回答
展开全部
将byte的2进制值转为01组合的字符显示,在Text1中输入0-255,Text2中显示00000000 - 11111111 Option Explicit Dim sHex As String Dim sBin As String Dim sBin1 As String Dim sj(1 To 8) As String * 1 Private Sub Command1_Click() Dim i As Integer sHex = Hex(Text1) HexToBin (sHex) If Len(sBin1) = 4 Then sBin1 = "0000" & sBin1 End If Text2 = sBin1 End Sub Public Function HexToBin(ByVal sHex As String) As String Const s1 = "0000101001101111000", s2 = "0125A4936DB7FEC8" Dim i As Integer, sBin As String sHex = UCase(sHex) For i = 1 To Len(sHex) sBin = sBin & Mid(s1, InStr(1, s2, Mid(sHex, i, 1)), 4) Next i HexToBin = sBin sBin1 = sBin End Function Private Sub Form_Load() Text1 = "" Text2 = "" End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询