Time difference calculator v.2 and copy multiple cells in dataGridView

This is another small tool (download here) which can be used in accounting calculating time difference in hours and minutes to decimal hours, giving a rate for such a difference and finally obtaining the product of rate and decimal time difference; the result can describe daily wage.

Additionally I made a table which is actually is Visual Basic 2010 gridDataView object, invented direct paste (by right mouse button or just press a button) for bulk time-data import, which could be copied from spreadsheet documents, and a possibility to copy out multiple selected cells. Rate can be set directly in table, then there is only need for recalculation for changes.

Otherwise, it is possible to fill the table manually.

The short story behind creating this software.

During the work finish party (cool and cheap place where to party - check the location of the post) one of my colleagues told me that he cant find easy solution to check his or his friend daily salary. I started to wonder, it should be very basic to create such calculation in excel. And what is possible doing in excel (download sample doc) could even better, user friendly and easier done in VB 2010.

Most interesting part was to figure out how to copy selected cells. I realized, that usually people using multiple cell selection does not copy more than "one block" of selection, actually excel does not allow to copy and paste more than one selection block. Such block is a rectangle and such rectangle has column and row index minimums and maximums.

Finding all the indexes of edges can be done through external function; Through looping that block I took all indexes in arraylists for both - columns and rows each have according arraylist, and wrote an external function to return minimum and maximum thus obtaining the indexes of selection block edges.

All data in table are text stored, so knowing the edges (indexes) of rectangle I can loop through both - outer loop over rows and inner loop over columns within minimum and maximum of rows and columns; in each loop accessing table cell by its id and building string for taking it in a clipboard.

But what happened if there is more than one selection block? For example, one large block containing multiple rows and columns and one separate cell somewhere outside? As I am finding minimum and maximum indexes for selected cells, such a cell will return one or both edge values. And the copying will occur including all other not_selected cells between these two selection blocks. 
Actually it makes no sense at all to try to copy and paste different selection blocks...

Nav komentāru:

Ierakstīt komentāru