'定义结构体
Public Structure RowData
Public CellData() As String
End Structure
'使用结构体
Dim myA() As RowData
初始化……?
ReDim Preserve myA(myA.Length + 1)
赋予新值……?
怎么初始化?怎么赋新值?是不是也要写构造函数。一上午都没弄出来,没用过VB.Net,只用过VB6
...全文
2648打赏收藏
结构体数组(动态增长),数组元素里还有数组成员,怎么定义和初始化?
如题 '定义结构体 Public Structure RowData Public CellData() As String End Structure '使用结构体 Dim myA() As RowData 初始化……? ReDim Preserve myA(myA.Length + 1) 赋予新值……? 怎么初始化?怎么赋新值?是不是也要写构造函数。一上午都没弄出来,没用过VB.Net,只用过VB6
为什么要通过构造函数传一个List呢
Public Class RowData
Private CellData As New List(Of String)
Sub New(ByVal p_cell As List(Of String))
CellData.AddRange(p_cell)
End Sub
End Class
还是不行啊
'定义类
Public Class RowData
Private CellData As List(Of String)
Sub New(ByVal p_cell As List(Of String))
CellData = p_cell
End Sub
End Class
'给列表赋值
Dim myList As New List(Of RowData)
Dim tempA As New List(Of String)
For i As Integer = 0 To 5
tempA.Add("A" + i.ToString())
Next
Dim myA As RowData = New RowData(tempA)
myList.Add(myA)
怎么访问myList里的元素?我想象中的myList(0).CellData(0)无效啊?