Click here to Skip to main content
15,889,909 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Access to arraylist globaly Pin
Christian Graus10-Jan-07 18:19
protectorChristian Graus10-Jan-07 18:19 
GeneralRe: Access to arraylist globaly Pin
WestSideRailways10-Jan-07 19:13
WestSideRailways10-Jan-07 19:13 
GeneralRe: Access to arraylist globaly Pin
Christian Graus11-Jan-07 0:52
protectorChristian Graus11-Jan-07 0:52 
QuestionSplash screen & Startup form Pin
kindman_nb10-Jan-07 9:35
kindman_nb10-Jan-07 9:35 
QuestionSerialization in vb2005 Pin
john_paul10-Jan-07 8:27
john_paul10-Jan-07 8:27 
AnswerRe: Serialization in vb2005 Pin
Christian Graus10-Jan-07 9:16
protectorChristian Graus10-Jan-07 9:16 
AnswerRe: Serialization in vb2005 Pin
Marc Paliotti10-Jan-07 9:18
Marc Paliotti10-Jan-07 9:18 
AnswerRe: Serialization in vb2005 Pin
nlarson1110-Jan-07 10:27
nlarson1110-Jan-07 10:27 
John,

<Serializable() _
public class MyEntity
public sName as string
<Xml.Serialization.XmlIgnore()>public oObj as object
.
.
end class

Note: private variables will not be serialized
Note: some variable types cannot be serialized
Note: if you dont' want the value to be seralized you need to ingore the value
Note: import these libraries
Imports System.io
Imports System.Xml
Imports System.Xml.Serialization

-------
To Serialize:

Public Function sSerializeEntity(ByVal oEntity As Object) As String
Dim oSerializer As New XmlSerializer(oEntity.GetType)
Dim oSR As New MemoryStream, bt() As Byte

Try
oSerializer.Serialize(oSR, oEntity)

bt = oSR.GetBuffer

sSerializeEntity = System.Text.Encoding.ASCII.GetString(bt)

oSR.Close()
oSR = Nothing
oSerializer = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
-----------
To Deserialize:

Public Sub DeSerializeEntity(ByVal sEntity As String, ByRef oEntity As Object)
Dim oSerializer As New XmlSerializer(oEntity.GetType)
Dim oSR As MemoryStream

Try
oSR = New MemoryStream(System.Text.Encoding.ASCII.GetBytes(sEntity))

oEntity = oSerializer.Deserialize(oSR)

oSR.Close()
oSR = Nothing
oSerializer = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

---------------
** to serlialize object **

Dim oMyEntity as new MyEntity
oMyEntity.sName = "Test"

dim sEntity As string = sSerializeEntity(oMyEntity)

'''''''serialized''''''' you can pass the value of sEntity anywhere

** to put back into an object **

Dim oMyEntity as new MyEntity

DeSerializeEntity(sEntity,oMyEntity)

'''''''deserialized''''''' now you can use the object

msgbox(oMyEntity.sName)



GeneralRe: Serialization in vb2005 Pin
john_paul10-Jan-07 13:41
john_paul10-Jan-07 13:41 
Questionhelp me:crystal report+access Pin
Yar e Mehrban10-Jan-07 6:32
Yar e Mehrban10-Jan-07 6:32 
QuestionTesting in VS.NET 2003 Pin
Marc Paliotti10-Jan-07 5:18
Marc Paliotti10-Jan-07 5:18 
QuestionPacakge & Deployment of Vb.net Project Pin
Amit Gorawadia10-Jan-07 4:18
Amit Gorawadia10-Jan-07 4:18 
AnswerRe: Pacakge & Deployment of Vb.net Project Pin
MatrixCoder10-Jan-07 5:22
MatrixCoder10-Jan-07 5:22 
QuestionWeb Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 3:58
professionalMarcus J. Smith10-Jan-07 3:58 
AnswerRe: Web Service - return XML as string???? Pin
Doctor Nick10-Jan-07 4:18
Doctor Nick10-Jan-07 4:18 
GeneralRe: Web Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 4:29
professionalMarcus J. Smith10-Jan-07 4:29 
GeneralRe: Web Service - return XML as string???? Pin
Doctor Nick10-Jan-07 4:34
Doctor Nick10-Jan-07 4:34 
GeneralRe: Web Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 4:41
professionalMarcus J. Smith10-Jan-07 4:41 
GeneralRe: Web Service - return XML as string???? Pin
Doctor Nick10-Jan-07 5:04
Doctor Nick10-Jan-07 5:04 
GeneralRe: Web Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 5:09
professionalMarcus J. Smith10-Jan-07 5:09 
GeneralRe: Web Service - return XML as string???? Pin
Doctor Nick10-Jan-07 5:16
Doctor Nick10-Jan-07 5:16 
GeneralRe: Web Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 5:25
professionalMarcus J. Smith10-Jan-07 5:25 
GeneralRe: Web Service - return XML as string???? Pin
Doctor Nick10-Jan-07 5:38
Doctor Nick10-Jan-07 5:38 
AnswerRe: Web Service - return XML as string???? Pin
mr_lasseter10-Jan-07 9:02
mr_lasseter10-Jan-07 9:02 
GeneralRe: Web Service - return XML as string???? Pin
Marcus J. Smith10-Jan-07 11:17
professionalMarcus J. Smith10-Jan-07 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.