Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Walk Through A Maze (xp)

    I am playing around with mazes and have set myself a task with which I am having problems. I am trying to follow a series of instructions which form a sort of maze. I am, as yet, unable to get to check the "condition" correctly of the cell contiguous with the activecell so that I can move in the required direction.
    I hope the attachment explains this further.
    Any takers?
    TIA.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Walk Through A Maze (xp)

    Based on your rather skimpy problem description:

    <code>
    Public Sub Maze()
    Dim bNotDone As Boolean
    bNotDone = True
    Do While bNotDone
    ActiveCell.Interior.ColorIndex = 4
    Select Case ActiveCell
    Case "Start==>"
    ActiveCell.Offset(0, 1).Select
    Case "Gold!"
    ActiveCell.Interior.ColorIndex = 6
    bNotDone = False
    Case "D"
    ActiveCell.Offset(1, 0).Select
    Case "U"
    ActiveCell.Offset(-1, 0).Select
    Case "L"
    ActiveCell.Offset(0, -1).Select
    Case "R"
    ActiveCell.Offset(0, 1).Select
    Case Else
    MsgBox "Invalid Mase"
    bNotDone = False
    End Select
    Application.Wait Now() + 1 / 86400
    Loop
    End Sub
    </code>
    Legare Coleman

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Walk Through A Maze (xp)

    Thank you for your time, Legare. I seem to be afflicted with the condition of "Insufficient Clarity", for which I apologise.
    I have tried your code but it is falling foul of the problem that I was experiencing, namely, that the code only looks at the active cell value and acts accordingly, instead of determining the next instruction by "looking" around itself.
    Your code always goes to B4 and displays the msg box.
    I hope I have explained myself on this occasion.
    Again, thanks for your expertise.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Walk Through A Maze (xp)

    That is what it should do with that maze. Cell B3 says go down, and when you get there there is no instruction of where to go next. That is an Invalid maze.

    What do you mean by '"looking" around itself'? What is it supposed to look at?
    Legare Coleman

  5. #5
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Walk Through A Maze (xp)

    B3 contains a typo. It should read "R". After amending it, everything works perfectly, even my code!!!

    Thanks for your time, and I hope I haven't raised your blood pressure too much. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I'll attempt to be more accurate with my descriptions, in future.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  6. #6
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Walk Through A Maze (xp)

    Looks like you're up to no good... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    These guys like mazes; just don't forget the Gold. Er Cheese! <img src=/S/mice.gif border=0 alt=mice width=50 height=25>
    - Ricky

  7. #7
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Walk Through A Maze (xp)

    On this occasion, Ricky, it's purely for educational reasons. But............you've got me thinking!
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

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