Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Startup counter? pronlem with saving files...

Status
Not open for further replies.

Croser

Technical User
Apr 19, 2011
1
0
0
CZ
Hello,
I wanted to make the application to count how many time sit has been runned..so I could make something like a restriction. You know..like run 10 time and get full version.. anyway..I did not find anything to count the startups..so I tried to make the application to create a folder on startup and save a empty file to it and count how many filed are in that folder and display it in label which will say ' Application started for ' + files in the folder + 'times'. I think I could work but I get stuck when I want to save the empty file..I even made a RichTextBox for savin it but it just don't save even if I put text in the textbox..it just create the folde. I have made other Apps which creates folder on startup and then a timer which will save the file every X mins and it worked I even copied the code from that project but still it isnt working... Ill post my code below please help me.

Code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SAPI
SAPI = CreateObject("sapi.spvoice")
SAPI.Speak("Welcome and Have Fun.")
System.IO.Directory.CreateDirectory("D:\Sys")
Threading.Thread.Sleep(50)
RichTextBox1.SaveFile("D:\Sys\nfo" + TimeOfDay + ".txt")
Dim s As String = "D:\Sys"
Dim d As New System.IO.DirectoryInfo(s)
Dim intFolders, intFiles As Integer
intFiles = d.GetFiles.GetUpperBound(0) + 1
Label6.Text = ("Program Started for " & intFiles.ToString & " time(s).")
End Sub
 
1. It's bad practice to use CreateObject in VB.Net
2. It's bad practice to use a RichTextBox if you're not working with Rich Text.
3. Why bother with a startup counter? If you save this data to a file, all the user will need to do will be to edit the file manually, or set up a scheduled job to edit the file.
4. Why not just go with something like a nag screen, or provide slightly reduced functionality without the full version?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top