Results 1 to 4 of 4

Thread: [RESOLVED] help with horizontal word finder in msflexgrid

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    16

    Resolved [RESOLVED] help with horizontal word finder in msflexgrid

    i'm doing horizontal right now. Fix my code please. Also i need help finding diagonal words.
    Attached Images Attached Images   

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: help with horizontal word finder in msflexgrid

    It would be more useful if you post the code directly into your post rather than post a picture of it.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: help with horizontal word finder in msflexgrid

    I think I'd adopt a different approach and mimic the same logic I'd use if I were solving it with pen and paper.

    1. Scan the Grid looking for the first letter of the word I'm searching for.
    2. When I find it I'd then scan in turn, to the right, left, above, below, diagonal left to right down, diagonal right to left down, diagonal right to left up, diagonal left to right up, for the next letter.
    3. If I find the next letter I'd continue, in whatever direction I was going, looking for the next letter and so on until I've found all the letters required.
    4. If at any stage I didn't find the letter I was loking for, I'd continue changing direction until either I find it or I've looked in all directions.
    5. If I've looked in all possible directions and hadn't found a letter then I'd repeat from step (1) looking for the first letter again

    You can use the length of the word you're looking for to avoid checking in directions that will go over the edges of the Grid. e.g. If I were looking for 'Flux' and I found an 'F' in Row 2, Col 2 there would be no point in looking in directions that took you to the left or above (since Flux has 4 letters and there are not 3 cells above or to the left of 2,2)

    EDIT: A faster method might be to use InStr. e.g. start at 0,0 and copy everything to the right into a string then use InStr to see whether the word is in the string.If it isn't, then copy everything below into a string and use InStr again, if it isn't then copy the diagonal(s) and repeat until the word is found.
    Last edited by Doogle; Apr 23rd, 2013 at 02:16 AM.

  4. #4
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,272

    Re: help with horizontal word finder in msflexgrid

    Continuing with Doogle's theme it may be more efficient to analyse the grid first, populating an array of strings for all vertical, horizontal and diagonal 'paths'.

    i.e. for a 3x3 grid you'd have 3 horizontal paths, 3 vertical paths, 3 diagonal left-to-right/up-to-down paths and 3 diagonal left-to-right/down-to-up paths

    e.g. Consider this grid

    ABC
    DEF
    GHI

    You'd have 'ABC','DEF','GHI','ADG','BEH','CFI','G','DH','AEI','BF','C','A','DB','GEC','HF','I'

    That's all you need. If you have a function that reverses the string you are looking for, you can look it up in the above array...
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

Posting Permissions

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



Click Here to Expand Forum to Full Width