How does determining row count and column count work

Discussion created by priyanka_mehta on Mar 30, 2011
Hi all,

below is the code to determine the column and row number when x,y is provided.
I am not able to understand how does it work. Is 0.5 a standard value. Whats the role of these constant numbers. Can I modify the formula in some way from LHS to RHS to find x,y if I have row number and column no.

Dim pixelWidth As Double, pixelHeight As Double
   pixelWidth = pREnv.Width / pRLayer.ColumnCount
    pixelHeight = pREnv.Height / pRLayer.RowCount

' determine which row & col were clicked on
   Dim lRow As Long, lCol As Long
    lCol = Round(Abs(x - pREnv.XMin - (0.5 * pixelWidth)) / pixelWidth)
    lRow = Round(Abs(y - pREnv.YMax + (0.5 * pixelHeight)) / pixelHeight)

Thanks and Regards,