VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get and Save how many times your prog was loaded

by DoWnLoHo (14 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (14 Votes)

This code will allow you to Save & Get how many times your program has been loaded.
Add a few lines of code to your program's main forms' load procedure. Very easy to understand.

Code Returns
Returns as Long

Rate Get and Save how many times your prog was loaded

Public Sub SetLoaded()
'put this in your main forms' Load procedure
'this will set the count
Dim lTemp As Long, sPath As String
lTemp& = GetLoaded&
If Right$(App.Path, 1) <> "\" Then sPath$ = App.Path & "\" & App.EXEName & ".tmp" Else sPath$ = App.Path & App.EXEName & ".tmp"
Open sPath$ For Output As #1
Print #1, lTemp& + 1
Close #1
End Sub
Public Function GetLoaded() As Long
'call this to get how many times program has been loaded
On Error Resume Next
Dim sPath As String, sTemp As String
If Right$(App.Path, 1) <> "\" Then sPath$ = App.Path & "\" & App.EXEName & ".tmp" Else sPath$ = App.Path & App.EXEName & ".tmp"
Open sPath$ For Input As #1
sTemp$ = Input(LOF(1), #1)
Close #1
If sTemp$ = "" Then GetLoaded& = 0 Else GetLoaded& = CLng(sTemp$)
End Function
'works well
'DoWnLoHo

Download this snippet    Add to My Saved Code

Get and Save how many times your prog was loaded Comments

No comments have been posted about Get and Save how many times your prog was loaded. Why not be the first to post a comment about Get and Save how many times your prog was loaded.

Post your comment

Subject:
Message:
0/1000 characters