Lifetime Counter that Doesn't Reset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atetz785
    New Member
    • Jul 2007
    • 6

    Lifetime Counter that Doesn't Reset

    I am writting a program in which I want to have a lifetime counter that doesn't reset when I close and reopen the program.

    The program is designed to take input and print it into a work order type form and I want there to be a counter for the work order number that continually increases by 1 everytime the form is made no matter if the program is closed inbetween uses.

    atetz785
  • SkinHead
    New Member
    • Jun 2007
    • 39

    #2
    You're going to have to save the 'Counter' information outside of the application. The easiest way is probably a text file, that is read in as part of the application initialisation.

    Comment

    • MikeTheBike
      Recognized Expert Contributor
      • Jun 2007
      • 640

      #3
      Originally posted by atetz785
      I am writting a program in which I want to have a lifetime counter that doesn't reset when I close and reopen the program.

      The program is designed to take input and print it into a work order type form and I want there to be a counter for the work order number that continually increases by 1 everytime the form is made no matter if the program is closed inbetween uses.

      atetz785
      If you are in Excel, then save the number to a hidden sheet.

      Otherwise the options I can think of are

      Retrieve/save to/from a database file
      Retrieve/save to/from other external (text?) file
      or save in the registry (don't ask me how - I've successfully avoided such things, so far... ).


      MTB

      Comment

      • atetz785
        New Member
        • Jul 2007
        • 6

        #4
        When I try saving the counter to a hidden sheet, Visual Basic doesn't find the worksheet to select the cell. Is there a different way to select the cell on a hidden sheet other than the code below or is it just not possible to select hidden sheets.

        Sheets("Sheet1" ).Select
        Range("D8").Sel ect

        Comment

        • MikeTheBike
          Recognized Expert Contributor
          • Jun 2007
          • 640

          #5
          Originally posted by atetz785
          When I try saving the counter to a hidden sheet, Visual Basic doesn't find the worksheet to select the cell. Is there a different way to select the cell on a hidden sheet other than the code below or is it just not possible to select hidden sheets.

          Sheets("Sheet1" ).Select
          Range("D8").Sel ect
          What happens?

          Don't Select the sheet just read/write to it ie

          CurrentNo=Sheet s("Sheet1").Ran ge("D8") or whatever
          and
          Sheets("Sheet1" ).Range("D8")= Current No +1

          Tip
          I would give the cell a Name (Say Counter) and refer to that ie

          CurrentNo = Range("Counter" )

          Range("Counter" ) = CurrentNo+1

          HTH


          MTB

          Comment

          • fplesco
            New Member
            • Jul 2007
            • 82

            #6
            Hi atetz785 -

            I'd like to assume that you dont have problems with the codes you want for your program. I mean, that your program works to what really is intended and you just want to simply save the counter that you dont want to reset. This might help you.

            Try using the system registry like this.

            Getting values to the registry
            [CODE]
            Counter = GetSetting(APP. EXENAME,"COUNTE RS","TASK COUNT")
            [CODE]

            Saving values to the registry
            [CODE]
            SaveSetting APP.EXENAME,"CO UNTERS","TASK COUNT", Counter + 1
            [CODE]

            Counter must be a GLOBAL variable.

            Hope this would help.

            Have a nice day.

            Comment

            • MikeTheBike
              Recognized Expert Contributor
              • Jun 2007
              • 640

              #7
              Originally posted by fplesco
              Hi atetz785 -

              I'd like to assume that you dont have problems with the codes you want for your program. I mean, that your program works to what really is intended and you just want to simply save the counter that you dont want to reset. This might help you.

              Try using the system registry like this.

              Getting values to the registry
              [CODE]
              Counter = GetSetting(APP. EXENAME,"COUNTE RS","TASK COUNT")
              [CODE]

              Saving values to the registry
              [CODE]
              SaveSetting APP.EXENAME,"CO UNTERS","TASK COUNT", Counter + 1
              [CODE]

              Counter must be a GLOBAL variable.

              Hope this would help.

              Have a nice day.
              Hi fplesco

              Although I did suggest this in a previous post (but never used), on reflection I think this would be a bad idea if more than one person use the spreadsheet/program on different machines, as they all would have there own counter value??


              MTB

              Comment

              Working...