Really need help -.-
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Help?
mandai wrote:Source?Code: Select all?File.WriteAllText("selected.txt", ListBox1.SelectedItem.ToString()) File.WriteAllText("textbox.txt", TextBox1.Text)
Yo after years of googling.. i found the solution
it helped me.. so it should help you!
if you have a save button. DELETE IT!
you dont need it.
THIS IS FOR LISTBOX SAVING.
okay on form_load add this:
IF YOU ADD A ME.CLOSE CODE then your ganna get an error when pressing it
so if you wanna close it just press the form 'X" button on top : )
+Rep me if it helped : ))
it helped me.. so it should help you!
if you have a save button. DELETE IT!
you dont need it.
THIS IS FOR LISTBOX SAVING.
okay on form_load add this:
Code: Select all
Then add this code on form_close:
'ontop of private sub add this:
Private Const APP_NAME As String = "SaveRestoreListBox"
Private Const SECTION_NAME As String = "Items"
'then under private sub:
Dim i As Integer = 0
Do
Dim new_value As String = GetSetting(APP_NAME, _
SECTION_NAME, "Item" & i.ToString())
If new_value.Length = 0 Then Exit Do
ListBox1.Items.Add(new_value)
i += 1
Loop
Code: Select all
THERE YOUR DONE!~For i As Integer = 0 To ListBox1.Items.Count - 1
SaveSetting(APP_NAME, SECTION_NAME, "Item" & _
i.ToString(), ListBox1.Items(i).ToString())
SaveSetting(APP_NAME, SECTION_NAME, "Item" & _
i.ToString(), ListBox2.Items(i).ToString())
SaveSetting(APP_NAME, SECTION_NAME, "Item" & _
i.ToString(), ListBox3.Items(i).ToString())
Next i
IF YOU ADD A ME.CLOSE CODE then your ganna get an error when pressing it
so if you wanna close it just press the form 'X" button on top : )
+Rep me if it helped : ))
NVM !!!!!!!!!!!!!! :evil: I STILL GET AN ERROR..
coders out there tyr it. and maybe you know what to do?
coders out there tyr it. and maybe you know what to do?
What are we trying to do? Save/load some listbox items?
Code: Select all
Dim lines As List(Of String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Clear()
Dim lines_a As String() = File.ReadAllLines("lines.txt")
lines = New List(Of String)(lines_a)
For i As Integer = 0 To lines.Count - 1
ListBox1.Items.Add(lines(i))
Next
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
lines.Add("new item")
File.WriteAllLines("lines.txt", lines.ToArray())
Form1_Load(Nothing, Nothing)
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
lines.RemoveAt(ListBox1.SelectedIndex)
File.WriteAllLines("lines.txt", lines.ToArray())
Form1_Load(Nothing, Nothing)
End Sub
Copyright Information
Copyright © Codenstuff.com 2020 - 2023