'建筑,供水,供电,结构,供暖,环境 Public oldValueFactor(0 To 5) As Double Public oldValue(0 To 5) As Integer Public newValueFactor(0 To 5) As Double Public newValue(0 To 5) As Integer Public idLen As Integer Public id As String Public nameLen As Integer Public name As String Public placeLen As Integer Public place As String Public situationLen As Integer Public situation As String Public oldTotal As Integer '总分 Public newTotal As Integer
Public oldLen As Integer Public oldPic() As Byte Public newLen As Integer Public newPic() As Byte '图片 Public Sub New() oldLen = 0 newLen = 0 Dim j As Integer For j = 0 To 5 oldValueFactor(j) = New Double() oldValue(j) = New Double() newValueFactor(j) = New Double() newValue(j) = New Double() Next End Sub End Class
Public Class ProjectSet Public nNum As Integer '1000000 Public pros(0 To 100000) As Project Public Sub New() nNum = 0 End Sub Public Sub LoadFromFile(ByVal fileName As String) Dim Stream As FileStream Dim BinaryStreamReader As BinaryReader Try Stream = New FileStream(fileName, FileMode.Open) BinaryStreamReader = New BinaryReader(Stream) nNum = BinaryStreamReader.ReadInt32() Catch E As Exception Return End Try Dim i As Integer For i = 0 To nNum - 1 pros(i) = New Project Dim j As Integer For j = 0 To 5 pros(i).oldValueFactor(j) = BinaryStreamReader.ReadDouble() pros(i).oldValue(j) = BinaryStreamReader.ReadInt32() pros(i).newValueFactor(j) = BinaryStreamReader.ReadDouble() pros(i).newValue(j) = BinaryStreamReader.ReadInt32() Next pros(i).id = BinaryStreamReader.ReadString() pros(i).name = BinaryStreamReader.ReadString() pros(i).place = BinaryStreamReader.ReadString() pros(i).situation = BinaryStreamReader.ReadString() pros(i).oldTotal = BinaryStreamReader.ReadInt32() pros(i).newTotal = BinaryStreamReader.ReadInt32() pros(i).oldLen = BinaryStreamReader.ReadInt32() pros(i).oldPic = BinaryStreamReader.ReadBytes(pros(i).oldLen) pros(i).newLen = BinaryStreamReader.ReadInt32() pros(i).newPic = BinaryStreamReader.ReadBytes(pros(i).newLen) Next BinaryStreamReader.Close() Stream.Close() End Sub Public Sub SaveToFile(ByVal fileName As String) Dim Stream = New FileStream(fileName, FileMode.Create) Dim BinaryStream As New BinaryWriter(Stream) BinaryStream.Write(nNum) Dim i As Integer For i = 0 To nNum - 1 Dim j As Integer For j = 0 To 5 BinaryStream.Write(pros(i).oldValueFactor(j)) BinaryStream.Write(pros(i).oldValue(j)) BinaryStream.Write(pros(i).newValueFactor(j)) BinaryStream.Write(pros(i).newValue(j)) Next BinaryStream.Write(pros(i).id) BinaryStream.Write(pros(i).name) BinaryStream.Write(pros(i).place) BinaryStream.Write(pros(i).situation) BinaryStream.Write(pros(i).oldTotal) BinaryStream.Write(pros(i).newTotal) BinaryStream.Write(pros(i).oldLen) BinaryStream.Write(pros(i).oldPic) BinaryStream.Write(pros(i).newLen) BinaryStream.Write(pros(i).newPic) Next BinaryStream.Close() Stream.Close() End Sub Public Sub AddProject(ByVal project As Project) pros(nNum) = project nNum += 1 End Sub Public Sub DeleteProject(ByVal nIndex As Integer) Dim i As Integer For i = nIndex To nNum - 2 pros(i) = pros(i + 1) Next nNum -= 1 End Sub Public Function FindProject(ByVal id As String) As Integer Dim i As Integer For i = 0 To nNum - 1 If id = pros(i).id Then Return i End If Next Return -1 End Function End Class