Save Help - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9) +----- Thread: Save Help (/showthread.php?tid=646) |
Save Help - manishshrestha60 - 09-14-2012 Hi, BP Forums Can anyone help me with save the Vb data. I am working a project and the main point of the project is that you can only click one button and it becomes disable. then if the person closes the program and opens it the button is still suppose to be disable until for 7 days or more . Please help me!!!!!!!! Re: Save Help - brandonio21 - 09-14-2012 Well, there are several methods to do this. You can either use a Settings method, Registry method, or File method. However, there is an old forum topic which discusses how to create a program trial type thing. <!-- l --><a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=22&t=315&p=1099&sid=37203ca7b51b3686a328545a2b827a64#p1099">viewtopic.php?f=22&t=315&p=1099&sid=37203ca7b51b3686a328545a2b827a64#p1099</a><!-- l --> If this doesn't help, be sure to say so! Re: Save Help - Vinwarez - 09-14-2012 Hello, manishshrestha60. This is really easy to do. Basically what you need to do is mark the date the button is pressed, increment it for seven days and then set button's enabled property to false. 1. Go to your project's settings (Project -> <name> Properties...) and create these settings: Code: NAME TYPE SCOPE VALUE 2. Declare three string variables which will be used as a current date. [code2=vbnet]Private day, month, year As String[/code2] 3. Double-click on the form to generate Form.Load event. Rewrite or copy'n'paste this code snippet: [code2=vbnet]' Sets the date variables to computer's current date. day = My.Computer.Clock.LocalTime.Day month = My.Computer.Clock.LocalTime.Month year = My.Computer.Clock.LocalTime.Year ' Checks whether the button is enabled or disabled. ' If the button is disabled, it makes sure it is disabled ' for seven days. If My.Settings.disabled = False Then My.Settings.day = day My.Settings.month = month My.Settings.year = year Button1.Enabled = True Else Button1.Enabled = False If year = My.Settings.year Then If month = My.Settings.month Then If day = (My.Settings.day + 7) Or day > (My.Settings.day + 7) Then My.Settings.disabled = False Button1.Enabled = True End If Else My.Settings.disabled = False Button1.Enabled = True End If Else My.Settings.disabled = False Button1.Enabled = True End If End If My.Settings.Save() ' <-- Don't delete this line. It's important.[/code2] 4. Double-click on the button. Rewrite or copy'n'paste this code snippet: [code2=vbnet]My.Settings.disabled = True Button1.Enabled = False[/code2] I assure you this works because I tested it by changing my computer's date. If you're stuck at some point in this tutorial, click here to see the full code. I hope this helped you. NOTE: I was writing this when there was no replies and when I needed the link to the thread, I noticed that Brandon has already replied. Since I took my time write this, I decided to post it anyway. |