请教 字节数组-》字符串-》文本框-》字符串-》字节数组 为何不等的问题,感激!

rise139 2003-10-09 01:30:33
dim a() as byte
dim b() as byte

dim c as string
dim d as string

c=a()

text1.text= c
d = text1.text

b()=d

为何 a() <> b() ?

请教正确如何实现以上过程。谢谢!
...全文
46 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Gelim 2003-10-11
  • 打赏
  • 举报
回复
dim a() as byte
dim b() as byte

dim c as string
dim d as string

c=StrConv(a, vbUnicode)

text1.text= c
d = text1.text

b=StrConv(d, vbUnicode)

则a() = b() !
pigsanddogs 2003-10-10
  • 打赏
  • 举报
回复
text1.text = c1 。。。1
c2 = text1.text 。。。2
c1 不一定等于 c2
因为如果c1如果包含text控件不能解释的字符,text会把他消失掉
经过1的时候。text已经不等于c1的值了
rainstormmaster 2003-10-10
  • 打赏
  • 举报
回复
不知道你要干什么,将数组a复制成b吗,如果是的话,可以这样(用for循环):
Private Sub Command1_Click()
Dim a() As Byte
Dim b() As Byte

Dim c As String
Dim d As String
ReDim a(3)
Dim i As Long, j As Long


For i = 0 To 3
a(i) = 80 + i
Next
i = UBound(a)
ReDim b(i)
For j = 0 To i
b(j) = a(j)
Next
End Sub

也可以这样:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Sub Command1_Click()
Dim a() As Byte
Dim b() As Byte

Dim c As String
Dim d As String
ReDim a(3)
Dim i As Long, j As Long


For i = 0 To 3
a(i) = 80 + i
Next
i = UBound(a)
ReDim b(i)
CopyMemory b(0), a(0), i + 1

End Sub
rainstormmaster 2003-10-10
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim a() As Byte
Dim b() As Byte

Dim c As String
Dim d As String
ReDim a(3)

For i = 0 To 3
a(i) = 80 + i
Next
c = a()

Text1.Text = c
d = Text1.Text

b() = d
For i = 0 To UBound(b)
Debug.Print b(i)
Next
End Sub

经测试,a() =b()
flc 2003-10-10
  • 打赏
  • 举报
回复
类型不匹配
关注
lwm1977 2003-10-09
  • 打赏
  • 举报
回复
string转byte(),是不是有个chr(13)之类的东西干扰
rise139 2003-10-09
  • 打赏
  • 举报
回复
经过测试,这样好象也不成的呀
射天狼 2003-10-09
  • 打赏
  • 举报
回复
c = StrConv(a, vbUnicode)

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧