This function is used like this: TextBox1.Text = 32
cfg.write("Set Example_1", TextBox1.Text)
It Writes to the file exactly like this:
Set Example_1 "32"
What I need to know is how to make it change only whats in the "" when its saving the same Example (Set Example_1) instead of just creating a whole new line.
cfg.write("Set Example_1", TextBox1.Text)
It Writes to the file exactly like this:
Set Example_1 "32"
What I need to know is how to make it change only whats in the "" when its saving the same Example (Set Example_1) instead of just creating a whole new line.
Code:
Public path As String = Application.StartupPath & "\config.cfg"
Public Function Write(ByVal Name As String, ByVal Value As String) As Boolean
Dim fs As StreamWriter
If File.Exists(path) = False Then
Create the file.
fs = File.CreateText(path)
fs.Write(Name & " """ & Value & """" & vbCrLf)
fs.Close()
Else
fs = File.AppendText(path)
fs.Write(Name & " """ & Value & """" & vbCrLf)
fs.Close()
End If
End Function