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

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

Birthday

Post by zingo » Thu Jan 22, 2009 1:21 pm

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

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Thu Jan 22, 2009 2:02 pm

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 ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.

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

I have a calendar program

Post by burger2227 » Fri Jan 23, 2009 1:47 am

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

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

Post by zingo » Sat Jan 24, 2009 12:53 pm

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.

Post Reply