Page 1 of 1

Birthday

Posted: Thu Jan 22, 2009 1:21 pm
by zingo
I started with qbasic last week, so im pretty bad

Now the thing i need help with:
Im trying to make a program that tells you how many days it is to your birth day. but i have problem. you tell the program when you were born and the program says it is x days left until your birthday.
Say what i can do or say where i can read about how to do it.
hope you understand me :)

Here is the code:
CLS
1
INPUT "Whats your personal number, 'ddmmyyyy****'four last", pers$
pers1 = VAL(LEFT$(pers$, 8))
dd = VAL(MID$(DATE$, 4, 3))
dm = VAL(LEFT$(DATE$, 2))
dar = VAL(RIGHT$(DATE$, 4))
pd = VAL(LEFT$(pers$, 2))
pm = VAL(MID$(pers$, 3, 2))
par = VAL(MID$(pers$, 5, 4))
IF dm > pm THEN GOTO
IF dm = pm THEN GOTO 2
IF dm < pm THEN GOTO
2
IF dd = pd THEN
PRINT "Happy birthday!"
GOTO 5
END IF
kd = dd - pd
kd = kd - kd - kd
IF dd - pd <0> 0 THEN
GOTO 4
END IF
3
FOR o = (dm) TO (pm) STEP -1
SELECT CASE o
CASE 1, 3, 5, 7, 8, 10, 12
dag = 31
CASE 4, 6, 9, 11
dag = 30
CASE 2
dag = 28
END SELECT
dag = dag + dag
NEXT o

Posted: Thu Jan 22, 2009 2:02 pm
by moneo
Hi Zingo, welcome to the forum.

Date handling programs are quite difficult.
You need to consider logic for:

1) Knowing how to determine if a given year is a leap year or not.

2) Figuring out the maximum number of days in any month. For February, you need to know if the year is a leap year.

3) You need to do a thorough validation on the input date provided. For your particular problem, you need to assume that the input birthdate is in the current year.

Since you are still learning, I honestly suggest you chose a simpler problem. This one can get quite frustrating.

Regards..... Moneo

I have a calendar program

Posted: Fri Jan 23, 2009 1:47 am
by burger2227
You can download an idea of what is involved here:

http://www.qbasicstation.com/index.php? ... &filecat=2

Look for Calendos.Zip

The program uses data from year 2000 to calculate leap years and the first day of a year. Look in the Leapyear SUB using View in the QB menu.

Then you have to calculate the days each month to find the days.

Like Moneo said, this stuff is way beyond LET and GOTO, but it may help you some.

Ted

Posted: Sat Jan 24, 2009 12:53 pm
by zingo
i will look little on the site if i dont get anything i will try do something else, Ty for the help i will check it out
if i find a solution i will post it here.