Results 1 to 5 of 5

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.)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I think it would be smarter to allocate the cell indexes as rows of say 20 (even though you dont use them

    a devious trick would be to have a border all the way round the data set you want to use

    000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019
    020 021..039
    ....etc
    220 221............................................... .....................239

    000..019 are ghost/guard cells.. have blank or false values
    020 & 036,037,038,039 likewise
    220..239 likewise

    that way round you always have a valid reference for the 'other' cell.

    failing that I think you would have to call a function which would trap the that proposed cell is out of bounds
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I wish I could but I 1-150 is an array and I have other events programmed on which cell(1) to cell(150).... are selected. I'd have to redo a lot of programming already done to re-configure it to a different array with a border array. I will do this as a last resort but I was hoping there was an equation I could use with the existing array/cells.

    I could add another array BorderCells(1)....BorderCells(15), BorderCell(16), BorderCell(30),etc... but I'm not sure how I could use that to detect diagonally and if it crosses that BorderCell.
    Last edited by pkstormy; 07-04-07 at 12:56.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    There is a guy on SQLTeam planning on putting together SQL Chess. He has written article #1. Essentially, what you require is exactly the same as a bishop's moves yes?
    See if it is any use - might give you more ideas (for example he models his board in a table rather than an array - might be easier to use....).

    http://www.sqlteam.com/article/sqlch...inking-in-sets

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks Pootle. This helps even though it means a bit of reprogramming to accomplish it. I was hoping to avoid this and somehow do it with a one dimensional array instead of two (i.e. Cell(20) to Cell(35) verses Cell(2,5) to Cell(3,6)) but I'm beginning to think that it's not possible with a one dimensional array.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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