## Birthday

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

zingo
Newbie
Posts: 2
Joined: Thu Jan 22, 2009 12:14 pm

### Birthday

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\$, )
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

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico
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
If you are behind me, follow.
If you are not doing anything,
Get out of the way.

burger2227
Veteran
Posts: 2420
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

### I have a calendar program

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