Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim myObject As MySerializableClass = New MySerializableClass
Insert code to set properties and fields of the object.
Dim mySerializer As XmlSerializer = New XmlSerializer(GetType(MySerializableClass))
To write to a file, create a StreamWriter object.
Dim myWriter As StreamWriter = New StreamWriter("contacts.xml")
mySerializer.Serialize(myWriter, myObject)
End Sub
Dim myObject As MySerializableClass = New MySerializableClass
Public Class Contact
Private members of the class
Private m_FirstName As String
Private m_LastName As String
Public properties that are saved in the XML file
Public Property FirstName() As String
Get
Return m_FirstName
End Get
Set(Value As String)
m_FirstName = Value
End Set
End Property
Public Property LastName() As String
Get
Return m_LastName
End Get
Set(Value As String)
m_LastName = Value
End Set
End Property
End Class
Dim contacts As New ArrayList()
Dim person As New Contact()
person.FirstName = "Bucky"
person.LastName = "Fuller"
contacts.Add(person)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dsUsers As New DataSet
dsUsers.ReadXml("..\contacts.xml")
With Contactsgrid
.CaptionText = "Your Contacts"
.DataSource = dsUsers.Tables(0)
End With
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim myObject As MySerializableClass = New MySerializableClass
Insert code to set properties and fields of the object.
Dim mySerializer As XmlSerializer = New XmlSerializer(GetType(MySerializableClass))
To write to a file, create a StreamWriter object.
Dim myWriter As StreamWriter = New StreamWriter("contacts.xml")
mySerializer.Serialize(myWriter, myObject)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dsUsers.ReadXml("contacts.xml")
With Contactsgrid
.CaptionText = "Your Contacts"
.DataSource = dsUsers.Tables(0)
End With
End Sub
Private Sub Button1_Click (whatever goes in here which i cant remember)
DsUsers.WriteXml("contacts.xml")
End Sub
Dim dsUsers As New DataSet