Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

qbasic help

Status
Not open for further replies.

beyondsociety

Technical User
May 9, 2002
40
US
I want to specify a certain date in my program instead of just using the date$ command which diplays the current date. I also want to do the same thing with the time$ command. If anybody could help me out I would appreciate it.
 
What??

Don't understand.

Post what code you have done so far and try explaining in detail what you want. In that way, we may guide you better. --MiggyD

Never be afraid to try something new. Remember that amateurs built the Ark. Professionals built the Titanic.
 
do you want to change the system date and time?

say the current system date is 01/01/85
you want to update it to the current date
DATE$ = "06/18/02"
 
m% = VAL(LEFT$(DATE$, 2)) '----month number
D% = VAL(MID$(DATE$, 4, 2)) '--day number
y% = VAL(RIGHT$(DATE$, 4)) '---year number
days$ = "Fri Sat Sun Mon Tue Wed Thu "
num! = VAL(MID$("000303060811131619212426", (m% - 1) * 2 + 1, 2))
yr! = y%
dy! = yr! * 365 + INT((y% - 1) \ 4) + (m% - 1) * 28
dy! = dy! + num! - ((m% > 2) AND (y% MOD 4 = 0)) + D%
weekday$ = (MID$(days$, (dy! - INT(dy! \ 7) * 7) * 9 + 1, 9))
month$ = " JanFebMarAprMayJunJulAugSepOctNovDec" '
mon$ = (MID$(month$, (m% * 3), 3))
hr% = VAL(LEFT$(TIME$, 2))
min$ = MID$(TIME$, 3, 3)
IF hr% > 11 THEN suff$ = "pm" ELSE suff$ = "am"
IF hr% > 12 THEN hr% = hr% - 12
IF hr% = 0 THEN hr% = 12

COLOR 15, 1: CLS
LOCATE 3, 5: PRINT USING "##\ \ \\ \ \"; hr%; min$; suff$; weekday$
LOCATE 5, 5: PRINT USING " \ \ ## ####"; mon$; D%; y%


===================================================
then if you wanted to update the TIME somewhere in your program then add the bottom code

make a SUB called CLOCK , then put the above code in it
then just CALL CLOCK from the code below

minsav = VAL(MID$(TIME$, 4, 2))
DO
'---put some code in here
min2 = VAL(MID$(TIME$, 4, 2))
IF min2 <> min THEN min = min2: CALL clock
LOOP

this code might give you some ideas
you might have to ADJUST lines of above code because it doesn't paste correctly in the width of Tek_Tips

MaxRace Software - Larry Meaux
ET_Analyst for DragRacers
Support Israel - Genesis 12:3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top