October 09, 2024, 03:34:44 PM

News:

IWBasic runs in Windows 11!


Age Calculator

Started by Brian, April 28, 2017, 11:21:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,

I've been messing lately with my family history. I needed something to work out how old a person is/was on a certain date. There are quite a few internet-only solutions out there, but there is nothing like rolling your own
I've borrowed some of Bill's Date Routine code to come up with this, and I must admit it got a bit messy, and I have had to calafudge some of it, but I've tested it with known dates and known days of people close to me, and it seems to hold up
Let me know if you have any suggestions. Oh, it is a Project, which lets me embed the bitmaps into the exe for portability

Brian

billhsln

Interesting program.  I like the interface.

A small quick short cut in SUB TidyData,
iMonth = USING("0##",monthx+1)
iDay = USING("0##",dayx)


These 2 commands should replace all this code:

IF monthx=0 THEN iMonth="01"
IF monthx=1 THEN iMonth="02"
IF monthx=2 THEN iMonth="03"
IF monthx=3 THEN iMonth="04"
IF monthx=4 THEN iMonth="05"
IF monthx=5 THEN iMonth="06"
IF monthx=6 THEN iMonth="07"
IF monthx=7 THEN iMonth="08"
IF monthx=8 THEN iMonth="09"
IF monthx=9 THEN iMonth="10"
IF monthx=10 THEN iMonth="11"
IF monthx=11 THEN iMonth="12"
IF monthx>12 THEN iMonth=LTRIM$(STR$(monthx+1))
IF dayx=1 THEN iDay="01"
IF dayx=2 THEN iDay="02"
IF dayx=3 THEN iDay="03"
IF dayx=4 THEN iDay="04"
IF dayx=5 THEN iDay="05"
IF dayx=6 THEN iDay="06"
IF dayx=7 THEN iDay="07"
IF dayx=8 THEN iDay="08"
IF dayx=9 THEN iDay="09"
IF dayx>9 THEN iDay=LTRIM$(STR$(dayx))


Just trying to help make your coding a little quicker.

Great Program.

Thanks for sharing,
Bill
When all else fails, get a bigger hammer.

Egil

Thanks Brian!

My granddaughter just discovered that granddad is way too old....



Egil
Support Amateur Radio  -  Have a ham  for dinner!

Brian

Bill and Egil,

Thanks for your comments - it is nice to get some feedback, and ideas of how to simplify the code

I did admit to a bit of calafudging, so Bill's code is very welcome - thank you

Brian

Brian

Whoops!

I had to do an update. When I tested it this morning, it failed to pick up that it was the first of the month. Very minor update, actually

I've also tightened up some of the code, thanks to Bill; also instead of using "comboString+comboString=" I've used "comboString+="; and there are now Tooltips for the two bitmap buttons; and a few more tweaks in there, as well

Brian

Brian

May 01, 2017, 09:44:45 AM #5 Last Edit: May 01, 2017, 11:58:41 AM by Brian Pugh
Oh, this is embarrassing! I missed altering the code for resetting the date. Please change, before compiling:

CASE 13 'Reset date button
IF @NOTIFYCODE=0
ISTRING rDay[3]=DATE$("dd")

to

CASE 13 'Reset date button
IF @NOTIFYCODE=0
ISTRING rDay[3]=DATE$("d")

I've attached the updated program to this post, as well

Sorry,

Brian

Brian

Hello,

While messing with the Age Calculator, I was getting frustrated typing the same old dates in to test if it was working correctly, so I thought I would add a list of preset dates that you could just use without having to actually type dates in
Works like the first offering, but the button "Preset Dates" brings up a dialog with a built-in list of interesting people with their birthdays
You can also add your own by typing a name and then typing the date of birth. Don't forget, the format is DD/MM/YYYY, for us across the Pond!
Type the name and date, and then press "Add this entry" and it gets put into the list, and the list is then saved to file
If you select a name from the listbox, and then press "Use selected" the dialog is closed and the dates are automatically calculated
The "Close" button closes the dialog, but will save the listbox data if the list has altered
You can always edit the text file manually - it is only a simple Notepad file. All you need to type is a name, space and then the date. Using the Preset Dates dialog to put an entry in automatically adds the space after a name

Enjoy - and let me know if any problems, or suggestions

Brian

billhsln

Looking good.  Might want to add a way to edit entries.  I entered my Name and date, but after having a senior moment, noticed that I entered it as mm/dd/yyyy, instead of dd/mm/yyyy, my mistake.  Corrected by fixing the .TXT file, but having an edit option would be nice for those of us who screw things up occasionally.  Would also help for misspelled names.

Thanks,
Bill
When all else fails, get a bigger hammer.

billhsln

This is not a direct question on your program, but I was wondering.  Is there some way to get what the user wants for default date format.  Your program does dd/mm/yyyy, I have set my system to prefer yyyy-mm-dd, I wonder if there is a way to get that info out of the system.

Thanks,
Bill
When all else fails, get a bigger hammer.

Brian

Bill
I am sure there will be. Good suggestions - I will look them all up
Brian