Bra49er

I want to save text in the textboxes using a save button BUT i don't want to save it to any files just in the textboxes until its changed by the user and saved again so that everytime the application is executed the text will still be there. would this be a property of the textbox or is it even possible to do this. I really don't want to use a database or lists or files just the same text in the textbox after the savebutton is clicked. thank you so much.


Re: Visual Basic Express Edition save text in textboxes

ssta

The following will work:

  1. Add TextBox1 to your form

  2. Right-click on your application and go to Properties

  3. Make sure Enable Application Framework is checked

  4. Check Save My.Settings on Shutdown

  5. Click the Settings tab

  6. Add a new Setting named 'SavedText', set the type to String and the scope to User

  7. Add the following code to the Form.Load handler:

      TextBox1.DataBindings.Add("text", My.Settings, "SavedText")






Re: Visual Basic Express Edition save text in textboxes

pinoyz

Hi Bra49er,

Try to use Settings....under application properties-> Settings-> Value (try to add what do you want)

To Load the Setting in textbox

Textbox1.text = My.Settings.Nameofyourstring

To Change the Value

My.Settings.Nameofyourstring = Textbox1.text

My.Settings.Save

Regards






Re: Visual Basic Express Edition save text in textboxes

Bra49er

ssta wrote:

The following will work:

  1. Add TextBox1 to your form

  2. Right-click on your application and go to Properties

  3. Make sure Enable Application Framework is checked

  4. Check Save My.Settings on Shutdown

  5. Click the Settings tab

  6. Add a new Setting named 'SavedText', set the type to String and the scope to User

  7. Add the following code to the Form.Load handler:

      TextBox1.DataBindings.Add("text", My.Settings, "SavedText")



how do i make work with the savebutton




Re: Visual Basic Express Edition save text in textboxes

pinoyz

To save

My.Settings.Nameofyourstring = Textbox1.text

My.Settings.Save






Re: Visual Basic Express Edition save text in textboxes

ssta

The settings are save automatically if My.SaveSettings on Shutdown is checked otherwise you can call My.Settings.Save manually with you save button.




Re: Visual Basic Express Edition save text in textboxes

Bra49er

ok so this is what i did but i want only the save button to save it and this code made it save and stay saved without the button. Did i do something wrong


Private Sub IncomeForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.DataBindings.Add("text", My.Settings, "Textsaved")

End Sub


Private Sub button_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_save.Click

My.Settings.textsaved = TextBox1.Text
My.Settings.Save()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

My.Settings.textsaved = TextBox1.Text

My.Settings.Save()

End Sub





Re: Visual Basic Express Edition save text in textboxes

js06

the databinding code is binding your textbox to your setting location

it will save the text automatically when you close the app if you have save my.settings on shutdown checked in your project properties (uncheck this if you want to save only with the save button)

the textchanged event will update and save your setting every time you type something in the box

Remove this code completely if you only want to save with the save button






Re: Visual Basic Express Edition save text in textboxes

Bra49er

ok so i unchecked the databinding code and removed the textchanged event code completely. my save button is still not saving the text with the code that I have in it. am i missing something




Re: Visual Basic Express Edition save text in textboxes

js06

ok why don't you try something different

make sure that you have the correct name of the setting in your code

the setting name below in bold needs to be your setting name

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

TextBox1.text = My.Settings.Textsaved

End Sub


Private Sub button_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_save.Click

My.Settings.textsaved = TextBox1.Text
My.Settings.Save()


End Sub







Re: Visual Basic Express Edition save text in textboxes

Bra49er

ok that worked, so if i want more things on the form to save with that button like other textboxes and comboboxes and datetimepickers do i just substitute textbox1.text with combobox1.text or does a different word go there or is there an easier way to list them or just use one word or phrase to make them all save thank you for being so patient with me Smile




Re: Visual Basic Express Edition save text in textboxes

js06

to make this easy on you

you should make a setting location for each item you want to save

then you would use seperate code for each one

let's say you have 2 textboxes - you want to save the text from each one so you can recall the text when you run again

create a setting for each one

then refer to them just like above

save button click event

my.settings.textbox1settingname = me.textbox1.text

my.settings.textbox2settingname = me.textbox2.text

then you can call the text when the form loads

just use the same code above but change it to match your setting names

form load event

me.textbox1.text = my.settings.textbox1settingname

etc...