Cryptonic (04-24-2013)
Cryptonic (04-24-2013)
Well, I'm trying to create a program that will hold data. The full explanation is in op. Basically, I need a method to store data from a combo box so when I restart the program, the data will still be there.
I don't want to use save.settings because when you move/copy the program, the settings get deleted... Unless there's a way around that
Use .xml
Its so simple to use as well!
Create a class and write this:
To Load,Code:Public _SomeString As String Public Sub New(ByVal SomeString As String) Me._SomeString = SomeString End Sub 'For your case, you'll need to make an array just like this!
To write:Code:Dim fileLoc As String = Application.StartupPath & "\Settings.xml" Public Sub LoadSettings() If My.Computer.FileSystem.FileExists(fileLoc) Then Dim document As XmlReader = New XmlTextReader(fileLoc) While (document.Read()) Dim type = document.NodeType If (type = XmlNodeType.Element) Then If (document.Name = "ThisString") Then dim x as string = document.ReadInnerXml.ToString() End If End While document.Close() End If
Public Sub SaveSettings(ByVal Hallo As String)
You can figure the rest out on ya own. I won't spoon feed anyoneCode:Dim set as New clsInfoSettings(Hallo) Dim settings As XmlWriterSettings = New XmlWriterSettings() With settings .Indent = True End With Using writer As XmlWriter = XmlWriter.Create(fileLoc, settings) With writer .WriteStartDocument() .WriteStartElement("Program_Settings") .WriteElementString("ThisString", SomeString) .WriteEndElement() .WriteEndDocument() .Close() End With End Using End Sub
Cryptonic (04-29-2013)
Thanks for the help, though I already recieved help from 1UP. Since you never posted back I thought you wouldn't have bothered. This is good for anyone else that needs it though
//Solved
-VM/PM me if it's not