Please use this Board for QBasic related requests ( file research, programming, etc.)
Moderators:Administrator, Global Moderator
-
iggy
- Newbie
- Posts:2
- Joined:Sun Dec 16, 2007 7:42 pm
converting decimal to HH:MM:SS?
Post
by iggy » Sun Dec 16, 2007 7:46 pm
hello everyone,
for school i got an assignment, wich stated we had to create a program in Quickbasic that would let you convert a decimal time (like 3,14 hours) to HH:MM:SS.
now i know how to do this on paper or in my head or what ever, but i have absolutly no clue how i should do this in quickbasic
does anyone have some pointers or tips for me?
any help is much appreciated!
thx in advance

-
iggy
- Newbie
- Posts:2
- Joined:Sun Dec 16, 2007 7:42 pm
Post
by iggy » Sun Dec 16, 2007 11:34 pm
ive found it meself
Code: Select all
CLS
PRINT "Hallo, Met dit programma kun je Decimale tijden omrekenen naar UU:MM:SS"
INPUT "Voer een decimaal getal in alstublieft", getal!
uren = FIX(getal!)
switch1 = (60 * (getal - uren))
minuten = FIX(switch1)
switch2 = switch1 - minuten
seconden = FIX((switch2 * 60))
PRINT uren; ":"; minuten; ":"; seconden
-
Valerie
- Sr. Member
- Posts:54
- Joined:Wed Dec 15, 2004 8:10 am
- Location:Coromandel, NZ
Post
by Valerie » Mon Dec 17, 2007 8:26 am
Hello Iggy & welcome to the forums.
-
Ralph
- QBasic God
- Posts:134
- Joined:Sat Nov 06, 2004 2:27 am
- Location:Katy, Texas
Post
by Ralph » Wed Dec 19, 2007 6:17 am
That's great, Iggy! Glad you found a program that does what you need. The program seems very clear and well done.
Now, PLEASE read the program and try to understand each and every line of it, as that is the only way that you will benefit from the program, believe me!
Then, if you have questions, folks here will be happy to help you out with good answers.
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.
-
Dragoncat
- Newbie
- Posts:5
- Joined:Wed Jul 30, 2008 7:06 pm
-
Contact:
Post
by Dragoncat » Thu Aug 07, 2008 11:09 am
this is assuming you are using seconds as the input or such..
here is another way:
create a blank string (empty ) to hold the desired output : tim$
like this tim$=""
split the number into separate parts:
hour%=seconds%/3600
min% = (seconds% mod 60)/60
sec =seconds% mod 60
then convert each to strings
tim$ =str$(hour%)+":"+str$(min%)+":"+str$(sec%)
something like that anyways...
-
dziekan_tek
- Newbie
- Posts:3
- Joined:Tue Oct 14, 2008 6:51 pm
Post
by dziekan_tek » Tue Oct 14, 2008 8:55 pm
Dragoncat wrote:
min% = (seconds% mod 60)/60
Everything's fine but here is a little mistake. It should be:
min% = (seconds% / 60) MOD 60
;-)
Cheers!