okay i have a simple program which allows a user to enter information in and it saves an object to a text file.
Now i open a new project and want to use the text file that was previously created and read the objects into the new project, am so lost any hlep??
Thanks
Original Project
Now i open a new project and want to use the text file that was previously created and read the objects into the new project, am so lost any hlep??
Thanks
Original Project
VB.NET:
[SIZE=2][COLOR=#0000ff]Option[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Strict[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]On[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.IO[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Runtime.Serialization[/SIZE]
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] System.Runtime.Serialization.Formatters.Binary[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Form1[/SIZE]
[SIZE=2][COLOR=#0000ff]Inherits[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.Form[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] mFilename [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = "PInfo.txt"[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] saveMenuItem_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] saveMenuItem.Click[/SIZE]
[SIZE=2][COLOR=#008000]'Save the information[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ablackBook [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] BlackBook[/SIZE]
[SIZE=2]ablackBook.Name = nameTextBox.Text[/SIZE]
[SIZE=2]ablackBook.PhoneNumber = phoneTextBox.Text[/SIZE]
[SIZE=2]ablackBook.PagerNumber = pagerTextBox.Text[/SIZE]
[SIZE=2]ablackBook.CellNumber = cellTextBox.Text[/SIZE]
[SIZE=2]ablackBook.VoiceNumber = voiceTextBox.Text[/SIZE]
[SIZE=2]ablackBook.Email = emailTextBox.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] personalInformationFileStream [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] FileStream(mFilename, FileMode.Append)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] personalInformationBinaryFormatter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] BinaryFormatter[/SIZE]
[SIZE=2]personalInformationBinaryFormatter.Serialize(personalInformationFileStream, ablackBook)[/SIZE]
[SIZE=2]personalInformationFileStream.Close()[/SIZE]
[SIZE=2]MessageBox.Show("Information Saved")[/SIZE]
[SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] clearMenuItem_Click(sender, e)[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]MessageBox.Show("Could not save the file")[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
Last edited: