For the purpose of the serialization in Vb.net I have got the code below:
Code:
Option Strict We
Option Explicit
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
Public Class SerialDeserialLameGrid
Public num As Integer
Public num2 As Integer
Private Grille (num, num2) As String
Public Property grid () As Array
Get
grid = Grille
End Get
Set(ByVal value As Array)
Grille = CType(value, String(,))
End Set
End Property
Public Sub SerialiseLameGrid (ByVal path As String, ByVal Nbline As Integer,
ByVal number As Integer, ByVal Matrix (,) As String,
ByVal ctrl As LameGrid.Grid)
Sun flux As Stream File.Create = (path) 'preparation flow
Sun serializer As New BinaryFormatter
For x = 0 To Nbline - 1 'For each row
For y = 0 To number - 1 'For each column
Grid (x, y) = ctrl (x, y). Text 'fill a table with lamegrid
Me. Grille = Grid 'we set the table to the object grid
Next
Next
serializer.Serialize (flux, Me. Grille) 'we serialize
flux.Flush ()
flux.Close()
flux.Dispose ()
End Sub
Public Sub DeserialiseLamegrid (ByVal path As String, ByVal Nbline As Integer,
ByVal number As Integer, ByVal Matrix (,) As String,
ByVal ctrl As LameGrid.Grid)
Sun flux As Stream File.OpenRead = (path) 'is prepared feeds
Sun Deserializer As New BinaryFormatter
Me. Grille = CType(deserializer.Deserialize (flux) String(,)) 'on the file to deserialize the object grid
Matrix = CType(Me. Grille, String(,)) 'you put the object in a grid array
For x = 0 To num
For y = 0 To num2
ctrl (x, y). Text = Grid (x, y) 'we fill the table since lamegrid
Next
Next
ctrl.Refresh ()
flux.Close()
flux.Dispose ()
End Sub
End Class
Bookmarks