473,326 Members | 2,173 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,326 software developers and data experts.

Help to convert seconds to minutes needed

4
Hello everyone I am trying to find a way to convert seconds to minutes in the script below -
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdBegin_Click()
  2. On Error Resume Next
  3. n = Val(txttime.Text) * 60
  4. tmrClock.Enabled = True
  5. cmdStop.Enabled = True
  6.  
  7. End Sub
  8.  
  9. Dim n As Integer
  10.  
  11. Private Sub cmdStop_Click()
  12.     tmrClock.Enabled = False
  13.     Label1.Caption = "Enter Time In Minutes"
  14.     txttime.Text = ""
  15.     Label2.Visible = False
  16.  
  17.     cmdBegin.Enabled = True
  18.     cmdStop.Enabled = False
  19.  
  20. Main.Caption = "Application Close"
  21.  
  22. End Sub
  23.  
  24.  
  25.  
  26. Private Sub tmrClock_Timer()
  27. Main.Caption = "Seconds left = " & n - 1
  28. If txttime = "60" Then Label2.Visible = True
  29. If Label2.Visible Then sndPlay = sndPlaySound("beep.wav", 0)
  30.  
  31. If n <> 0 Then
  32.     n = n - 1
  33.     txttime.Text = n
  34.     Label1.Caption = "Number Of Seconds Untill Close:"
  35.     cmdBegin.Enabled = False
  36.  
  37. Else
  38.     tmrClock.Enabled = False
  39.    'Shell "Rundll32 user,ExitWindows"
  40.      Unload Me
  41. End If
  42. End Sub
  43.  
thank you in advance
Mar 24 '08 #1
7 1540
debasisdas
8,127 Expert 4TB
From your code i am not sure what exactly you are trying to do ?

If you want to convert seconds to minutes then find out the total second and then divide bu 60.
Mar 24 '08 #2
jimmy1
4
From your code i am not sure what exactly you are trying to do ?

If you want to convert seconds to minutes then find out the total second and then divide bu 60.
The code is part of a countdown timer for an application to terminate after a given time, but I am unsure how to convert the seconds to minutes
As it is counting down in seconds.
Thanks for your reply.
Mar 24 '08 #3
jimmy1
4
The code is part of a countdown timer for an application to terminate after a given time, but I am unsure how to convert the seconds to minutes
As it is counting down in seconds.
Thanks for your reply.
I seem to have got it sorted but I am now getting a lot of decimal numbers after
the minutes were as I just want a short format of the time?
Mar 24 '08 #4
jg007
283 100+
I seem to have got it sorted but I am now getting a lot of decimal numbers after
the minutes were as I just want a short format of the time?
posted about 4 times without understanding the issue but I think I have worked out , you need to be assigning the value to another integer and not just setting the label to n/60
Mar 24 '08 #5
Killer42
8,435 Expert 8TB
posted about 4 times without understanding the issue but I think I have worked out , you need to be assigning the value to another integer and not just setting the label to n/60
You can also assign Int(n/60) - you don't necessarily have to put the value in another variable before using it.
Mar 25 '08 #6
!NoItAll
297 100+
Expand|Select|Wrap|Line Numbers
  1. Dim lSeconds As Long
  2. Dim iMinutes As Integer
  3. Dim iHours As Integer
  4.  
  5. Dim Seconds As Integer   'this represents your original number
  6. Seconds = 12574
  7.  
  8. iMinutes = Seconds \ 60   'integer division returns whole number
  9. iHours = iMinutes \ 60
  10. lSeconds = Seconds Mod iMinutes   'returns what's leftover
  11. iMinutes = iMinutes Mod 60
  12.  
'not really tested well
Mar 25 '08 #7
jimmy1
4
Dim lSeconds As Long
Dim iMinutes As Integer
Dim iHours As Integer

Dim Seconds As Integer 'this represents your original number
Seconds = 12574

iMinutes = Seconds \ 60 'integer division returns whole number
iHours = iMinutes \ 60
lSeconds = Seconds Mod iMinutes 'returns what's leftover
iMinutes = iMinutes Mod 60

'not really tested well
I have it sorted you have to use a back slash to clear the decimals and not
a forward slash
thanks for your help
Mar 25 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: kpp9c | last post by:
I am kind of in a bit of a jam (okay a big jam) and i was hoping that someone here could give me a quick hand. I had a few pages of time calculations to do. So, i just started in on them typing...
5
by: da Vinci | last post by:
Hi Gents, This is what I am trying to do. Say you have a double or a float with the value 14.5624 for example. How could I take that variable and get the 14 into an integer variable and the...
2
by: Rudi Groenewald | last post by:
Hi all. If I've got a query which has a field with seconds in it... how will I use the Convert function to get my field converted to the format: HH:MM:SS ? The field with the seconds in is...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Chris | last post by:
Hi, Can someone convert this to VB.NET Please. I am trying but for some reason it doesn't work. if (null != Request.QueryString) { secondsToWait = Request.QueryString; if...
7
by: tshad | last post by:
Is there a quick function in vb out there that will convert seconds to minutes and seconds? Thanks, Tom
2
by: 00_CP_D12 | last post by:
Is there an easy way in ASP.NET to convert seconds to Hours: Minutes: Seconds? For example, 65 seconds will return 0 hr, 1 min, 5 secs. Thanks...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
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...
1
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: 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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.