1. Hey Guest Did you know you can win an Honor 10 phone worth ₹33,000 and an additional ₹70,000 in paytm vouchers, just by replying to some threads and taking part in the discussions happening in the Honor Hub?

    What are you waiting for? Start commenting and start winning! Remember to read the instructions posted here.

    Dismiss Notice

Visual Basic Query

Discussion in 'QnA (read only)' started by godsownman, Mar 29, 2006.

Thread Status:
Not open for further replies.
  1. godsownman

    godsownman New Member

    Joined:
    Feb 22, 2005
    Messages:
    879
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Bombay
    I would like to know what is the code in VB to automatically stop an applications functioning after a fixed amount of executions.

    What I mean is I want to create a application which can be used to trial purposes.

    I want to know for curiosity sake.

    Thanks
     
  2. siriusb

    siriusb New Member

    Joined:
    May 12, 2005
    Messages:
    1,171
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Chennai, India, Asia, the Earth, the Solar system,
    Here's a simple way. You can create a hidden file or a registry key which holds a number. Your program, as soon as it's run, can check if the number is greater than allowed. If so, terminate program. Else, increment the number and run.
     
  3. ~Phenom~

    ~Phenom~ The No.1 Stupid

    Joined:
    May 17, 2005
    Messages:
    1,703
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    CYBERYARD
    yeah , siriusb is quite right.
    My friend was also telling me the same , when I had this query 2 months back. he said he has applied that succesfully.
     
  4. OP
    OP
    godsownman

    godsownman New Member

    Joined:
    Feb 22, 2005
    Messages:
    879
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Bombay
    To be honest, I am quite new to Visual Basic ,so I would greatly appreciate it if you all can please be a little more expressive it would aid me better.

    Thanks
     
  5. siriusb

    siriusb New Member

    Joined:
    May 12, 2005
    Messages:
    1,171
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Chennai, India, Asia, the Earth, the Solar system,
    Here's a small routine to check the number of times a program has been run. You can put an if statement somewhere to terminate the program after some count. This method uses registry keys. You can try ini or a simpe txt or a mdb file.
    Code:
    Private Sub Form_Load()
    
    Dim iCount As Integer
    iCount = Val(GetSetting("SomeAppName", "SomeSectionName", "iCount", "1"))
    
    MsgBox "You have run this program " & iCount & " times."
    SaveSetting "SomeAppName", "SomeSectionName", "iCount", Str(iCount + 1)
    
    End Sub
    The registry key will be created in "HKEY_CURRENT_USER\Software\VB and VBA Program Settings". If u want to avoid tampering by the users, you can create multiple keys and/or files and save the value in all of them, so if one of them is compromised you can have other copies. BUt if the user is determined, he can use simple tools to find out which files you are using. Nobody's safe.
     
  6. OP
    OP
    godsownman

    godsownman New Member

    Joined:
    Feb 22, 2005
    Messages:
    879
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Bombay
    Thanks a lot siriusb.

    I really appreciate the help.

    I will try it out.

    Thanks.
     
Thread Status:
Not open for further replies.

Share This Page