Results 1 to 3 of 3

Thread: Timer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2003
    Posts
    108

    Timer

    I am using VB.Net delveloping Web base application (Online examination). I'd like to monitor the exam in terms of the lenght of time. For example, after 25 minutes the exam will shut down automitically.

    I am thinking, after the form(WebForm1.aspx) loaded, there will be a timer shows on the top of the form. Starting form 00:00, and then when it reaches 25:00, the form will automatically unload. This is 1zjust my theory, but I have no idea how to do it. Does anybody know how to do this or even has better idea.

    Thank you in advance.

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    This code is for a desktop application rather than a web one, but hopefully it will give you some useful ideas.

    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.  
    4. #Region " Windows Form Designer generated code "
    5.  
    6.     Private gStopTime As Date
    7.     Private WithEvents tmr As New Timer()
    8.     Private Const INTERVAL As Double = 25
    9.  
    10.     Private Sub Form1_Load(ByVal sender As System.Object, _
    11.                            ByVal e As System.EventArgs) Handles MyBase.Load
    12.  
    13.         AddHandler Application.Idle, AddressOf UpdateClock
    14.  
    15.         With tmr
    16.             .Interval = 1000
    17.             .Start()
    18.         End With
    19.  
    20.         gStopTime = Now.AddSeconds(INTERVAL)
    21.  
    22.     End Sub
    23.  
    24.     Private Sub UpdateClock(ByVal sender As Object, ByVal e As EventArgs)
    25.  
    26.         If Now >= gStopTime Then
    27.             End
    28.         Else
    29.             lblTime.Text = DateDiff(DateInterval.Second, _
    30.                                         gStopTime.AddSeconds(-INTERVAL), Now)
    31.         End If
    32.  
    33.     End Sub
    34.  
    35.     Private Sub tmr_Tick(ByVal sender As Object, _
    36.                          ByVal e As System.EventArgs) Handles tmr.Tick
    37.  
    38.         Application.DoEvents()
    39.  
    40.     End Sub
    41. End Class
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2003
    Posts
    108
    Thanks! I'll give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width