|
-
Jan 14th, 2004, 12:18 AM
#1
Thread Starter
Lively Member
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.
-
Jan 14th, 2004, 06:09 AM
#2
This code is for a desktop application rather than a web one, but hopefully it will give you some useful ideas.
VB Code:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private gStopTime As Date
Private WithEvents tmr As New Timer()
Private Const INTERVAL As Double = 25
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Application.Idle, AddressOf UpdateClock
With tmr
.Interval = 1000
.Start()
End With
gStopTime = Now.AddSeconds(INTERVAL)
End Sub
Private Sub UpdateClock(ByVal sender As Object, ByVal e As EventArgs)
If Now >= gStopTime Then
End
Else
lblTime.Text = DateDiff(DateInterval.Second, _
gStopTime.AddSeconds(-INTERVAL), Now)
End If
End Sub
Private Sub tmr_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tmr.Tick
Application.DoEvents()
End Sub
End Class
This world is not my home. I'm just passing through.
-
Jan 14th, 2004, 12:11 PM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|