Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Remembering Variables

Remembering Variables

Scheduled Pinned Locked Moved C#
help
8 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johntwebb
    wrote on last edited by
    #1

    Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

    P A L N A 5 Replies Last reply
    0
    • J johntwebb

      Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

      P Online
      P Online
      PIEBALDconsult
      wrote on last edited by
      #2

      I hear there's this new thing called a database... :rolleyes: (If the number of "objects" is small and steady, perhaps an XML file will suffice.)

      1 Reply Last reply
      0
      • J johntwebb

        Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        You can store it in any storage location like DataBase, TextFile . When program is restarting read the content from the storage location.

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        J 1 Reply Last reply
        0
        • A Abhijit Jana

          You can store it in any storage location like DataBase, TextFile . When program is restarting read the content from the storage location.

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          J Offline
          J Offline
          johntwebb
          wrote on last edited by
          #4

          Yeah, I pretty much feel like an idiot. I use a database for my asp.net apps, but for some reason it never occurred to me to use it for a windows form app. Anyway, thanks for the answer.

          M 1 Reply Last reply
          0
          • J johntwebb

            Yeah, I pretty much feel like an idiot. I use a database for my asp.net apps, but for some reason it never occurred to me to use it for a windows form app. Anyway, thanks for the answer.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Ok so you have just added a new definition to not "thinking outside the box" - note the joke icon, this made me chuckle.

            1 Reply Last reply
            0
            • J johntwebb

              Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              If those options are global or per user (application user), the best place to store them is a database; if the options are per machine, store them in a custom xml file.

              1 Reply Last reply
              0
              • J johntwebb

                Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

                N Offline
                N Offline
                Natza Mitzi
                wrote on last edited by
                #7

                If your list is something that can be thought of as application settings , put it there. The application settings are easy to manage. Try to use but not abuse data bases (not even xml file dbs)

                Natza Mitzi Analysis Studio Statistical Analysis Software

                1 Reply Last reply
                0
                • J johntwebb

                  Hi, I have a program that opens an option form. For the options someone can basically list prices for various objects. I need to know how these prices can be remembered even after the program is shut down. I don't want to keep having to set the prices every time I run the program. Right now, I have a class which takes the prices and multiplies that by the quantity of an item. In that class I have static decimals. In the option form's button click I save a value to the class's static variables. Then I call those from the main form. Thanks for your help!

                  A Offline
                  A Offline
                  avigodse
                  wrote on last edited by
                  #8

                  Hi, u can use resource file, as they are part of application and not stored outside of it. u can access them using stream when required, conditionally prices dont change often.if u use this u dont need DB and not even shared variables.

                  Avinash S. Godse

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups