VB2010 Structure 数组复制问题

用VS2010的VB编程,定义了一个结构体,结构体中有一个数组
在对结构体的数组进行赋值时,出现了一个错误
不知改如何处理
Private Structure RTbuf
Dim buf() As Byte
Dim sss As String
End Structure

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim myBuff As New RTbuf

myBuff.sss = "OK!"
myBuff.buf(0) = &HAA'出错
myBuff.buf(2) = &HA1

End Sub
=========================================================

第1个回答  2014-04-30
应该是要使用重定义。追问

能贴一下代码么,非常感谢

追答
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As RTbuf
        ReDim b.buf(5)
        b.buf(1) = 5
        Label1.Text = b.buf(1)
    End Sub
End Class
Public Structure RTbuf
    Dim buf() As Byte
    Dim sss As String
End Structure

 

本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网