6 Replies - 2154 Views - Last Post: 23 August 2012 - 08:39 AM Rate Topic: -----

#1 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Storing form values on closing

Posted 16 August 2012 - 06:54 AM

Hi Dream.in.coders,

I have a question: is there a way to store the values of TextBoxes/NumericUpDownboxes when you close a form.

Some additional info:
  • Only the form closes, not the whole application.
  • My.settings is not an option because I need 600 values to be stored.
  • If the application closes, the data doesn't need to be stored any longer.

Is there anyone who has a solution?

Whaza

Is This A Good Question/Topic? 0
  • +

Replies To: Storing form values on closing

#2 rusoaica  Icon User is offline

  • They're watching you, Neo!
  • member icon

Reputation: 209
  • View blog
  • Posts: 672
  • Joined: 10-March 12

Re: Storing form values on closing

Posted 16 August 2012 - 07:03 AM

i see some posible ways of doing that... the most simple one would be to declare an array which holds the values and pass it to the main program, which remains opened, as you said... the next one, you could write a temporary text file on the disk which holds the data and delete it when the program closes... and the third one (but the less recomended one) would be to use registry keys for storing the data.. but that would be a little bit more complicated and dealing with registry requires a certain level of knowledge, or else you might do a great deal of damage to your programs or operating system.
Was This Post Helpful? 0
  • +
  • -

#3 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: Storing form values on closing

Posted 16 August 2012 - 07:10 AM

View Postrusoaica, on 16 August 2012 - 07:03 AM, said:

i see some posible ways of doing that... the most simple one would be to declare an array which holds the values and pass it to the main program, which remains opened, as you said... the next one, you could write a temporary text file on the disk which holds the data and delete it when the program closes... and the third one (but the less recomended one) would be to use registry keys for storing the data.. but that would be a little bit more complicated and dealing with registry requires a certain level of knowledge, or else you might do a great deal of damage to your programs or operating system.


Thank you,

I've got a question: how to declare to another form, I tried it yesterday but I couldn't get it...
Was This Post Helpful? 0
  • +
  • -

#4 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Storing form values on closing

Posted 16 August 2012 - 07:23 AM

Here I think you should get closer to the following concepts :
Isolated storage for storing files and serialization.

Also, you can try another approach(if there is not enough data to blow up your resources):
List(of T) where T can be any class(even if one defined by you). This list can be a property of a singleton. Make sure that in this case you free the resources as soon as you finish processing data.
Was This Post Helpful? 1
  • +
  • -

#5 rusoaica  Icon User is offline

  • They're watching you, Neo!
  • member icon

Reputation: 209
  • View blog
  • Posts: 672
  • Joined: 10-March 12

Re: Storing form values on closing

Posted 16 August 2012 - 07:26 AM

if the forms are in the same project, you simply declare a variable that is set to public... for example, if the program that is always open is form1 and the one that you want to retrieve data from is form2, you would declare in form1 a variable like this: Public Shared VariableName As String
in form2, you would pass values to it like this:
form1.VariableName = textbox1.text
the above line of code would assign to variable in form1 the text entered in a textbox in form2.
Else, if the forms are in different projects, you must use a namespace.
Was This Post Helpful? 1
  • +
  • -

#6 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: Storing form values on closing

Posted 23 August 2012 - 08:36 AM

Thank you all very much!

I'm using the Public Shared method, easy and just good for my needs!

Whaza
Was This Post Helpful? 0
  • +
  • -

#7 rusoaica  Icon User is offline

  • They're watching you, Neo!
  • member icon

Reputation: 209
  • View blog
  • Posts: 672
  • Joined: 10-March 12

Re: Storing form values on closing

Posted 23 August 2012 - 08:39 AM

im glad i could help you :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1