Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Serializing

Serializing

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Does anyone know how to save entries from a form to a file so they can be accessed for later viewing? I need to be able to pull the saved data back to the form it was saved from for later use. If anyone could help me with this I'd appreciate it. Thanks, ccotton333

    A R 2 Replies Last reply
    0
    • A Anonymous

      Does anyone know how to save entries from a form to a file so they can be accessed for later viewing? I need to be able to pull the saved data back to the form it was saved from for later use. If anyone could help me with this I'd appreciate it. Thanks, ccotton333

      A Offline
      A Offline
      Alberto Venditti
      wrote on last edited by
      #2

      If you are using a Windows Form, you could bind your "entries" (textboxes and other controls, I suppose) to a DataSet, and then use the WriteXML() and ReadXML() DataSet methods to serialize/deserialize it on a disk file.

      1 Reply Last reply
      0
      • A Anonymous

        Does anyone know how to save entries from a form to a file so they can be accessed for later viewing? I need to be able to pull the saved data back to the form it was saved from for later use. If anyone could help me with this I'd appreciate it. Thanks, ccotton333

        R Offline
        R Offline
        Randy S
        wrote on last edited by
        #3

        I would just save toa text file. Then you could read from the file to restore the valus. It is easy. You need System.io an duse stream reader and stream writer. I have a logon form which is check for a saved user name from a file at load. And on Enter I save the user name to this same file. That way the user name is remembered when the program is ended and then restarted. Ex. ( sName4User is global variable, Private Sub frmLogon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' This will retreive a user name from file if present. ' Opens a file stream for reading Dim myFS As New FileStream("c:\winnt\Temp\User.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.None) Dim myReader As New StreamReader(myFS) ' Assigning a reader sName4User = myReader.ReadLine 'Retreives username If Not sName4User Is Nothing Then txtName.Text = sName4User End If myReader.Close() End Sub Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click 'Storing username to file and closing if a username was entered If txtName.Text <> "" Then sName4User = txtName.Text ' Opens a file stream for reading Dim myFS As New FileStream("C:\winnt\Temp\User.txt", FileMode.OpenOrCreate) Dim myWriter As New StreamWriter(myFS) ' Assinging a reader myWriter.WriteLine(sName4User) ' Storing to the file myWriter.Close() Me.DialogResult = DialogResult.OK Else txtName.Text = "Enter a user name" txtName.Focus() txtName.SelectAll() End If End Sub

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups