自己写个函数吧:
private function ctob(c as string) as string
if len(c)<1 then
exit function
endif
c=left(c,1)
dim tmp as string,i as long
tmp=hex(asc(c))
for i =1 to len(tmp)
ctob=ctob & htob(mid(tmp,i,1))
next i
end function
function htob(h as string)
select case h
case "1"
htob="0001"
case "2"
htob="0010"
case "3"
htob="0011"
case "4"
htob="0100"
case "5"
htob="0101"
case "6"
htob="0110"
case "7"
htob="0111"
case "8"
htob="1000"
case "9"
htob="1001"
case "A"
htob="1010"
case "B"
htob="1011"
case "C"
htob="1100"
case "D"
htob="1101"
case "E"
htob="1111"
case "F"
htob="0010"
end select
end function
private function ctob(c as string) as string
if len(c)<1 then
exit function
endif
c=left(c,1)
dim tmp as string,i as long
tmp=hex(asc(c))
for i =1 to len(tmp)
ctob=ctob & htob(mid(tmp,i,1))
next i
end function
function htob(h as string)
select case h
case "1"
htob="0001"
case "2"
htob="0010"
case "3"
htob="0011"
case "4"
htob="0100"
case "5"
htob="0101"
case "6"
htob="0110"
case "7"
htob="0111"
case "8"
htob="1000"
case "9"
htob="1001"
case "A"
htob="1010"
case "B"
htob="1011"
case "C"
htob="1100"
case "D"
htob="1101"
case "E"
htob="1111"
case "F"
htob="0010"
end select
end function
b=StrConv("测试",vbFromUnicode)
我现在试一下小草的看看行不行
Dim s As String
s = "help"
Dim b(1 To 8) As Byte
CopyMemory b(1), ByVal StrPtr(s), LenB(s)
End Sub
Dim b() As Byte
b=StrConv("测试",vbFromUnicode)