我希望有人能帮我解决一些基础知识吗?
我正在尝试将大量数据加载到大型结构化数组中,使用它,然后以文本格式输出(模拟机器界面中的消息)。
这是代码的一个非常简化的版本,应该证明这一点:
Public Class Form3
Dim tstBody() As top_structure
Public Structure top_structure
Dim custValues1 As sub_structure1
Dim custValues2 As sub_structure2
End Structure
Public Structure sub_structure1
Public actualvalue1 As Integer
End Structure
Public Structure sub_structure2
Public actualvalue2 As Integer
End Structure
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tstBody(0).custValues1.actualvalue1 = 0
End Sub
End Class
我得到的错误说明: -
变量'tstBody'在赋值之前使用。在运行时可能会导致空引用异常。
我进行了搜索并尝试了“Public actualvalue1 As Integer = 0”,但在结构中这似乎失败了。
非常感谢