<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FClass_Module%2FStructure_Serialization</id>
		<title>VB.Net Tutorial/Class Module/Structure Serialization - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FClass_Module%2FStructure_Serialization"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Class_Module/Structure_Serialization&amp;action=history"/>
		<updated>2026-04-05T05:42:05Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Class_Module/Structure_Serialization&amp;diff=3472&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Class_Module/Structure_Serialization&amp;diff=3472&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Class_Module/Structure_Serialization&amp;diff=3473&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Class_Module/Structure_Serialization&amp;diff=3473&amp;oldid=prev"/>
				<updated>2010-05-26T12:55:43Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==RandomAccess file for storing the custom objects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.IO&lt;br /&gt;
public class Test&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim emp As New Employee&lt;br /&gt;
        Dim file_num As Integer = FreeFile()&lt;br /&gt;
        FileOpen(file_num, &amp;quot;MYFILE.DAT&amp;quot;, OpenMode.Random, _&lt;br /&gt;
             OpenAccess.ReadWrite, OpenShare.Shared, _&lt;br /&gt;
             Len(emp))&lt;br /&gt;
        FilePut(file_num, New Employee(1, &amp;quot;A&amp;quot;, &amp;quot;A&amp;quot;))&lt;br /&gt;
        FilePut(file_num, New Employee(2, &amp;quot;B&amp;quot;, &amp;quot;B&amp;quot;))&lt;br /&gt;
        FilePut(file_num, New Employee(3, &amp;quot;C&amp;quot;, &amp;quot;C&amp;quot;))&lt;br /&gt;
        Dim obj As ValueType = DirectCast(emp, ValueType)&lt;br /&gt;
        For Each i As Integer In New Integer() {3, 1,  2}&lt;br /&gt;
            FileGet(file_num, obj, i)&lt;br /&gt;
            emp = DirectCast(obj, Employee)&lt;br /&gt;
            Console.WriteLine(emp.ToString())&lt;br /&gt;
        Next i&lt;br /&gt;
        FileClose(file_num)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
    Public Structure Employee&lt;br /&gt;
        Public ID As Integer&lt;br /&gt;
        &amp;lt;VBFixedString(15)&amp;gt; Public FirstName As String&lt;br /&gt;
        &amp;lt;VBFixedString(15)&amp;gt; Public LastName As String&lt;br /&gt;
        Public Sub New(ByVal new_id As Integer, ByVal first_name As String, _&lt;br /&gt;
         ByVal last_name As String)&lt;br /&gt;
            ID = new_id&lt;br /&gt;
            FirstName = first_name&lt;br /&gt;
            LastName = last_name&lt;br /&gt;
        End Sub&lt;br /&gt;
        Public Overrides Function ToString() As String&lt;br /&gt;
            Return ID &amp;amp; &amp;quot;: &amp;quot; &amp;amp; FirstName &amp;amp; &amp;quot; &amp;quot; &amp;amp; LastName&lt;br /&gt;
        End Function&lt;br /&gt;
    End Structure&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;3: C               C&lt;br /&gt;
1: A               A&lt;br /&gt;
2: B               B&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Read Record (Structure) from binary file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.IO&lt;br /&gt;
Structure Product&lt;br /&gt;
    Dim ProdID As String&lt;br /&gt;
    Dim ProdDescription As String&lt;br /&gt;
    Dim ListPrice As Single&lt;br /&gt;
    Dim Available As Boolean&lt;br /&gt;
    Dim MinStock As Integer&lt;br /&gt;
End Structure&lt;br /&gt;
&lt;br /&gt;
public class Test&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim objBR As BinaryReader&lt;br /&gt;
        Dim objFS As FileStream&lt;br /&gt;
        Dim objProduct As New Product&lt;br /&gt;
        objFS = New FileStream(&amp;quot;Records.bin&amp;quot;, FileMode.Open, FileAccess.Read)&lt;br /&gt;
        objBR = New BinaryReader(objFS)&lt;br /&gt;
        objBR.BaseStream.Seek(0, SeekOrigin.Begin)&lt;br /&gt;
        While objFS.Position &amp;lt; objFS.Length&lt;br /&gt;
            objProduct = Nothing&lt;br /&gt;
            With objProduct&lt;br /&gt;
                .ProdID = objBR.ReadString&lt;br /&gt;
                .ProdDescription = objBR.ReadString&lt;br /&gt;
                .ListPrice = objBR.ReadSingle&lt;br /&gt;
                .Available = objBR.ReadBoolean&lt;br /&gt;
                .MinStock = objBR.ReadInt32&lt;br /&gt;
            End With&lt;br /&gt;
            ShowRecord(objProduct)&lt;br /&gt;
        End While&lt;br /&gt;
        objBR.Close()&lt;br /&gt;
        objFS.Close()&lt;br /&gt;
&lt;br /&gt;
   End Sub&lt;br /&gt;
    Private Shared Sub ShowRecord(ByVal objRecord As Product)&lt;br /&gt;
            Console.WriteLine(objRecord.ProdDescription)&lt;br /&gt;
            Console.WriteLine(objRecord.ListPrice.ToString)&lt;br /&gt;
            Console.WriteLine(objRecord.Available)&lt;br /&gt;
            Console.WriteLine(objRecord.MinStock.ToString)&lt;br /&gt;
    End Sub&lt;br /&gt;
End class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Save Structure to a binary file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.IO&lt;br /&gt;
Structure Product&lt;br /&gt;
    Dim ProdID As String&lt;br /&gt;
    Dim ProdDescription As String&lt;br /&gt;
    Dim ListPrice As Single&lt;br /&gt;
    Dim Available As Boolean&lt;br /&gt;
    Dim MinStock As Integer&lt;br /&gt;
End Structure&lt;br /&gt;
&lt;br /&gt;
public class Test&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim objBW As BinaryWriter&lt;br /&gt;
        Dim objFS As FileStream&lt;br /&gt;
        Dim objProduct As Product&lt;br /&gt;
        objFS = New FileStream(&amp;quot;Records.bin&amp;quot;, FileMode.OpenOrCreate, FileAccess.Write)&lt;br /&gt;
        objBW = New BinaryWriter(objFS)&lt;br /&gt;
        objBW.BaseStream.Seek(0, SeekOrigin.Begin)&lt;br /&gt;
        objProduct = New Product&lt;br /&gt;
        With objProduct&lt;br /&gt;
            .ProdID = &amp;quot;1&amp;quot;&lt;br /&gt;
            .ProdDescription = &amp;quot;AAA&amp;quot;&lt;br /&gt;
            .ListPrice = 4.99&lt;br /&gt;
            .Available = True&lt;br /&gt;
            .MinStock = 40&lt;br /&gt;
        End With&lt;br /&gt;
        SaveRecord(objBW, objProduct)&lt;br /&gt;
        objProduct = New Product&lt;br /&gt;
        With objProduct&lt;br /&gt;
            .ProdID = &amp;quot;2&amp;quot;&lt;br /&gt;
            .ProdDescription = &amp;quot;BBB&amp;quot;&lt;br /&gt;
            .ListPrice = 0.99&lt;br /&gt;
            .Available = True&lt;br /&gt;
            .MinStock = 1000&lt;br /&gt;
        End With&lt;br /&gt;
        SaveRecord(objBW, objProduct)&lt;br /&gt;
        objBW.Close()&lt;br /&gt;
        objFS.Close()&lt;br /&gt;
   End Sub&lt;br /&gt;
    Private Shared Sub SaveRecord(ByVal objWriter As BinaryWriter, ByVal objRecord As Product)&lt;br /&gt;
        With objWriter&lt;br /&gt;
            .Write(objRecord.ProdID)&lt;br /&gt;
            .Write(objRecord.ProdDescription)&lt;br /&gt;
            .Write(objRecord.ListPrice)&lt;br /&gt;
            .Write(objRecord.Available)&lt;br /&gt;
            .Write(objRecord.MinStock)&lt;br /&gt;
        End With&lt;br /&gt;
    End Sub   &lt;br /&gt;
End class&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>