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
converting decimal to HH:MM:SS?
Moderators:Administrator, Global Moderator
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
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.
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.
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...
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...
-
- Newbie
- Posts:3
- Joined:Tue Oct 14, 2008 6:51 pm