如何将Byte数组的一部分赋值给一个字符串?急!!

jxc1999 2003-12-17 03:46:39
比如
Dim b(1 to 20) As Byte

如何将Byte数组b(5)到b(10) 赋值给字符串s?
...全文
23 点赞 收藏 6
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxc1999 2003-12-18
请问 SoHo_Andy(冰)
回复
longki 2003-12-17

一个for和连接运算符"&"不就OK了!
回复
SoHo_Andy 2003-12-17
测试通过
Private Sub Command1_Click()
Dim n As Long
Dim arrBytes() As Byte

'读出二进制数据到数组
Open "d:\draw.ico" For Binary As 1
n = LOF(1)
ReDim arrBytes(1 To n) As Byte
Get 1, , arrBytes
Close 1

'读取二进制数组数据到字符串
Dim fileCon As String
Dim i As Long
For i = 10 To 150
fileCon = fileCon & CStr(arrBytes(i))
Next
MsgBox fileCon

End Sub
回复
flyingscv 2003-12-17
Dim a(20) As Byte
dim s as string

s=a '这儿也许根据需要用strconv
s=mid(a,x,y)
回复
landongfang 2003-12-17
Dim a(1 To 20) As Byte
Dim j
For j = 1 To 20
a(j) = Asc(j)

Next
Dim c As String
c = ""
For j = 5 To 10
c = c & Chr$(a(j))

Next
回复
landongfang 2003-12-17
Dim a() As Byte
Dim c As String
c = "12345678997"
a() = c
c = ""
c = a
c = Mid(c, 5, 10-5)
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7453

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告