473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

timer function

TJS
looking for example of timer function

something that will help me get to track user's elapsed time since last
refresh.

tried this but not working with session values correctly in my class

================================================== ==============
Function NewText() As String

Dim vString As String=" "
Dim dtm As DateTime
dtm = DateTime.Now()

If context.session("ScreenTimer") is nothing Then
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
else
context.session("TimeElapsed") = Hour(dtm) * 60 + Minute(dtm) -
cDBL(context.session("ScreenTimer"))
end if

If context.session("TimeElapsed") > 1 Then
vString= "new text here"
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
End If
return vString
End Function
Nov 18 '05 #1
1 1085
Hi,

This look pretty complicated :-)
Why don't you just store the DateTime directly in to Session?
Code is C#, but I think you get the idea...
store in session
****************

//store initial value:
Context.Session.Add("LastAccess", DateTime.Now);
get elapsed time
****************

//get time passed:
DateTime lastAccess = (DateTime)Session["LastAccess"];

//get the elapsed time
TimeSpan difference = DateTime.Now.Subtract(lastAccess);
hth, Philipp

TJS wrote:
looking for example of timer function

something that will help me get to track user's elapsed time since last
refresh.

tried this but not working with session values correctly in my class

================================================== ==============
Function NewText() As String

Dim vString As String=" "
Dim dtm As DateTime
dtm = DateTime.Now()

If context.session("ScreenTimer") is nothing Then
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
else
context.session("TimeElapsed") = Hour(dtm) * 60 + Minute(dtm) -
cDBL(context.session("ScreenTimer"))
end if

If context.session("TimeElapsed") > 1 Then
vString= "new text here"
context.session("ScreenTimer") = Hour(dtm) * 60 + Minute(dtm)
End If
return vString
End Function

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christine | last post by:
I've implemented a countdown timer for a tutorial web page that should give the user 45 minutes to complete the test, only to find that the timer is slowly 'losing' time. On average, it actually...
7
by: J. Hill | last post by:
I have a Windows Service with a timer but the .Tick event is not being fired/called. Don't know what code to include...I enabled and started the timer...I have the exact same code in a Windows...
6
by: Antti Laakso | last post by:
Hi i have function like above Public Sub halytystutkinta() Dim ds As New DataSet ds = dl2.HaeHalytys() Dim onkohal As Int16 onkohal = ds.Tables(0).Rows(0).Item("onkohalytys") halid =...
7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
1
by: jmgro | last post by:
I have spent way too much time trying to solve the following problem: I have a datalist with a timer in the footer template. It works wonderfully except when the user pages back, then forward,...
10
by: Ryan | last post by:
I'm creating a website that monitors the status of servers using My.Computer.Network.Ping. I'm looking for a way to fire off my Ping() function every second or so. I see a Timer control...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
4
by: jwriteclub | last post by:
Hello all, I have a quick question about timers in C#. I have a System.Windows.Forms.Timer timer (the kind you "drag" out of the toolbox. It looks something like this: public class...
7
by: ssecorp | last post by:
I am not clear about the results here. from timeit import Timer import Decorators def fib(n): a, b = 1, 0 while n: a, b, n = b, a+b, n-1
7
by: genesistr | last post by:
Hi, I have timer class and some classes use timer. but when i come back from timer with callback function, i can see this. properties. function Timer(dName, dCallback){ this.timer = null;...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.