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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with algorithm

Status
Not open for further replies.

crumpley

Programmer
Feb 21, 2002
3
US
I'm developing a scheduling application. It schedules office appointments for patients. It uses a tab control with several pages. Each page containe a Hierarchical Grid control. Each grid displays appointments for up to 3 different patients. Each patient's appointments are displayed in two consecutive columns. The first patient's appointments begin in the third column.

I am trying to develop an algorithm that determines when to go to the next page (after every third patient) and which column(s) should contain the current patient's appointment data.

I have the following variables defined:
NumPatients=running total of number of patients scheduled so far, including the current one.

MaxPerPage=maximum number of patients that can be placed on a single page.

MaxPages=total number of tabbed pages available for schedules.

I've developed one that uses a MOD 3 calculation, which can be made to work, but in my opinion is "clunky" because I have to use a special condition when NumPatients MOD 3=0.

My instincts tell me that there is a more direct way to do this using just the NumPatients and MaxPerPage variables and a straightforward calculation, probably involving the modulo division for the current column calculation and a Ceiling function for the current page calculation. Can anyone provide some insight?

Glenn Crumpley
 
John,
That seems to work fine. It not only tells me when to start a new page but I have a usable index for which column I'm currently work on. I knew there was a way to do this without a nested condition.

Thanks,
Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top