Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Auto Lock VB Application After 5 Min if Inactive

hwnahkhwnahk Member Posts: 18
AOA,
i want to lock my VB application (MDI, MIS System contain 20 forms) if it inactive for Specific Time mean if user not working on my application for last 5 min, application auto lock for security purpose

best regards and thanks

Comments

  • HackmanCHackmanC Member Posts: 441
    Use a Timer Control, insert into your form.
    This is only an example, you have to fill in the blanks.

    [code]Dim Minutes as Integer

    Private Sub Form_Load()
    Timer1.Interval = 1000 * 60 ' millis : 1 sec. * 60 = 1 min
    Timer1.Enabled = True
    Minutes = 0
    End Sub

    Private Sub Timer1_Timer()
    Minutes = Minutes + 1 ' <-- Increment one minute
    If Minutes = 5 Then ' <-- If you have 5 minutes
    Dim f as Form '
    For Each f in Forms ' <-- Hide all the child forms
    f.Hide '
    Next
    Me.Hide ' <-- Hide the main form

    Timer1.Enabled = False
    Minutes = 0

    PasswordForm.Show vbModal ' <-- Show the password form
    If PasswordValid Then ' <-- If the password is valid
    Form1.Show vbModal ' <-- Show the main form again
    Timer1.Enabled = True
    Else
    Dim f as Form
    For Each f in Forms ' <-- Unload all the child forms
    Unload f
    Next
    'Unload Me ' <-- Unload the main form
    End If
    End If
    End Sub
    [/code]
    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.