Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted
Serialization is a process of saving a state of an object to a file with exact properties that were set to it during serialization. Its like putting an object into a file for storage :).
  • 3 weeks later...
Posted

I dont mind what way they are saved, so any help you can offer would be realy appreciated, i just need all settings to be saved so that the user dosent have to change their settings every time they launch the program

 

Jonathan

Posted

Listen Jonathan, the professional way to do what you want is by connecting you application to a database, save everything the user does in an organized tables, and then on load you take the informatoin from the database. But now I'm not gonna teach you that because it need time, so I'll teach you how to write the settings into a file. Try the following:

 

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Me.Invoke(New SettingInvoke(AddressOf Me.GetSetting))

' SettingThread.Start()

GetSetting()

 

End Sub

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim FileWritrer As New IO.StreamWriter("C:\SavingSetting.txt")

FileWritrer.WriteLine(" CheckBox2," & CheckBox2.Checked)

FileWritrer.WriteLine(" " & TextBox1.Text)

FileWritrer.Flush() 'make sure everything is dumped into the file

FileWritrer.Close()

 

End Sub

 

' Private SettingThread As New Threading.Thread(AddressOf GetSetting)

 

Private Sub GetSetting()

 

Dim FileReader As New IO.StreamReader("C:\SavingSetting.txt")

Dim i As Integer = 0

Dim s, e As String

Dim x, y As Integer

While FileReader.Read() <> -1

If i = 0 Then

s = FileReader.ReadLine()

s = s.Substring(s.LastIndexOf(",") + 1)

If s.Equals("False") Then

CheckBox2.Checked = False

Else

CheckBox2.Checked = True

End If

Else

TextBox1.Text = FileReader.ReadLine()

End If

i = i + 1

End While

FileReader.Close()

' SettingThread.Abort()

End Sub

 

once you click on button2, the information are saved on a file on the C drive. Once you load the form, the settings are loaded again.

Posted

Yup, like i thought, i am having problems,

I have attached my program, (without any of the saving setting code)

Well the first problem is that when i use the code

'Me.Invoke(New SettingInvoke(AddressOf Me.GetSetting))
' SettingThread.Start()
GetSetting()

I get an error with the GetSetting() saying

C:\Documents and Settings\Jonathan.N-FORCE\My Documents\Visual Studio Projects\docked sidebar\XPEBarTest\Sidebar.vb(620): Argument not specified for parameter 'AppName' of 'Public Function GetSetting(AppName As String, Section As String, Key As String, [Default As String = ""]) As String'.

 

C:\Documents and Settings\Jonathan.N-FORCE\My Documents\Visual Studio Projects\docked sidebar\XPEBarTest\Sidebar.vb(620): Argument not specified for parameter 'Key' of 'Public Function GetSetting(AppName As String, Section As String, Key As String, [Default As String = ""]) As String'.

 

C:\Documents and Settings\Jonathan.N-FORCE\My Documents\Visual Studio Projects\docked sidebar\XPEBarTest\Sidebar.vb(620): Argument not specified for parameter 'Section' of 'Public Function GetSetting(AppName As String, Section As String, Key As String, [Default As String = ""]) As String'.

 

docked sidebar.zip

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...