Serializing #'s - Please help!

  • 19 years ago

    I am writing code for a label printer.  I want to have an idea when the labels are about to run out so I want to keep track of the # of labels that were printed.  How can I do this?  If I set a variable can I store this into the computers memory so next time I run my program and print out the labels, the stored number can incrament from there?  Please help me! It would be greatly appreciated!!!!  Thank you

  • 19 years ago

    How about saving the number printed in a file or the registry?

  • 19 years ago

    I did what you suggested.  It worked great! I am running into a problem though.  When I write something to the registry under my login name, it is not saved if someone else were to login under my computer.  I have a procedure counting the number of labels printed.  For example, if this number were 100 and I were log off and someone else were to login, the number will not show in the registry.  It would reappear if I were to login again.  So I guess it is local to the user.  Is there a way to write to the registry and have it the same for any user?  If so please let me know.

    Thank you

  • 19 years ago


    I think you should save the number you want to retain in a variable, and save that variable to disk.  (You could even write a small program separate to the label program that saves the initial value. eg.  MyVariable = 124. Save MyVariable to C
    Then when you run the program, write code at Form.Load to retrieve the value.

    Declare the variable in the Declarations section of Form1, if there is only one form, or in a module, if more than one form.

    Then write code, so that the last thing before terminating the program, the value is resaved back to disk.

    If I can be of more help, Email me at StevenRHicks@Hotmail.Com

    I hope I have been of assistance.

    Steven Hicks

  • 19 years ago

    Alternatively, use the Windows API registry functions to save the info to the HKEYLOCALMACHINE section instead of HKEYCURRENTUSER (which is where getsetting/savesetting saves it's data)

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann