我想要做的是将结构写入文本文件,让一些程序执行其工作(也写入文本文件)并将一些值写回结构中。
我希望能明白我想做什么。
Module NavigateStruct
Structure longStructure
Dim a As String
Dim b As nestedStructure
Structure nestedStructure
Dim c As Double
Dim d As nestednestedStructure
Structure nestednestedStructure
Dim e As Integer
End Structure
End Structure
End Structure
Sub navigateStructure()
Dim myStruct As longStructure
myStruct.b.c = 5.0
' somthing read from the text file
Dim str As String = "b-c"
Dim val1 As Double = 15.0
Dim val2 As Double
Dim splt() As String = str.Split(CChar("-"))
' splt ={"b", "c"}
' some Code to navigate to and set or retrieve value
' (use values in splt as fieldname)
' retrieve (that's not how it actually works, only something in simple pseudo code. Is there a way to write it in 'real' VB.net?)
val2=myStruct.[splt(0)].[splt(1)]
' set (pseudo code as well, but how does it work?)
myStruct.[splt(0)].[splt(1)] = val1
' val2 = 5
' myStruct.b.c = 15
End Sub
Sub writeStructureToString()
' some code running thru all elements of the structure including nested ones and writing 'parentname'-'childname' value
' result
' str = "a something"
' "b-c 5.0"
' "d-e 0"
' "... ..."
End Sub
结束模块