我有一个信封的地址程序,它从文本文件中读取信息。逐行读取文件,并将名称和地址分配给名为" tempaddr"的变量。然后将其添加到List(of nameaddress)变量中,该变量名为" address"。
参见下面的代码摘录:
Public Structure nameaddress
Friend name As String
Friend addressline() As String
Friend contact As String
Public Sub initialize()
ReDim addressline(3)
End Sub
Public Sub Clear()
name = ""
Array.Clear(addressline, 0, 3)
contact = ""
End Sub
Public Sub Add(ByVal na As nameaddress)
With na
name = .name
addressline = .addressline
.contact = .contact
End With
End Sub
End Structure
Public address As New List(Of nameaddress)
Public tempaddr As New nameaddress
.
.
.
address.Add(tempaddr)
问题是名称和联系人变量被分配了OK,但是地址线()变量被覆盖在"地址"中的所有先前条目上。列表。
我做错了什么。