用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
能贴一下代码么,非常感谢
追答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