Results 1 to 2 of 2

Thread: Equation

  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Equation

    I have a grid with cells 1 through 150 (15 columns by 10 rows) . I want to detect if the cells are diagonally BUT I don't want to go off the edge of the grid to do it. For example, cell 115 is diagonal to 83 (on the grid) and cell 106 is diagonal to 74 (but I want it to return false for 106 to 74 because you have to go off the edge of the grid.

    Here's what I'm using...

    If Int((OrgPieceIndex - Index) / 16) = ((OrgPieceIndex - Index) / 16) Then
    and
    If Int((OrgPieceIndex - Index) / 14) = ((OrgPieceIndex - Index) / 14) Then

    (Teddy - I have to ask this again as I'm having problems with the equation.)
    Last edited by pkstormy; 07-03-07 at 21:53.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Hmmmm, I overlooked that possiblity...

    You should be starting with this, which tells you that the two values are on vertically adjacent rows and the offset one column from each other:

    Code:
    If ABS(Ceiling(OrgPieceIndex / 15) - Ceiling(Index / 15)) = 1 and ABS(OrgPeiceIndex % 15 - Index % 15) = 1
    The extra step to check is to ensure you don't have one value % 15 = 1, and the other % 15 = 0, this would mean they're at opposite sides of the grid:

    Code:
    If Not (OrgPieceIndex mod 15 + Index mod 15) = 1 Then...
    You know those were modulo operators in my first post and not divisors right?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •