A VB6 Form has a Label & a CommandButton. When this application is used in the trial version mode, users can use it only 5 times. As & when the application is run, the user should be shown how many times he has already used the application in the Label. The CommandButton should be visible only when the user runs the application for the sixth time otherwise the CommandButton should always be hidden. After the user has used it 5 times, he should be shown a message in the Label saying "Trial version expired" along with the CommandButton clicking which the application should terminate. I tried it this way:
VB Code:
  1. Option Explicit
  2. Private Sub Form_Load()
  3.     Dim Count As Integer
  4.     Dim NumOfRuns As Integer
  5.    
  6.     NumOfRuns = Val(GetSetting("VBAPP", "TRIAL", "RUNS", "0"))
  7.     NumOfRuns = NumOfRuns + 1
  8.     SaveSetting "VBAPP", "TRIAL", "RUNS", NumOfRuns
  9.  
  10.     Count = GetSetting("VBAPP", "TRIAL", "RUNS")
  11.     If (Count = 1) Then
  12.         lblTrial.Caption = "You have used the trial version 1 time"
  13.     ElseIf (Count >= 2 And Count <= 5) Then
  14.         lblTrial.Caption = "You have used the trial version " & Count & " times"
  15.     ElseIf (Count > 5) Then
  16.         lblTrial.Caption = "Trial version expired"
  17.         cmdExit.Visible = True
  18.     End If
  19. End Sub
But when the code is run from the IDE, the Form with the Label doesn't show up irrespective of the no. of times the application has been run. Where am I erring?

Please note that the key gets created in the registry successfully.

Thanks,

Arpan