Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2005, 08:02 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default WordSearch - Please Help!

Hi

I'm building a wordsearch program which uses a text box to display the actual word search (12 x 12 letters). I've managed to get it to search left-right and right-left ok.

Does anyone know how to search up or down the columns? Or even diagonally?

Please help!!

Thank you!
 
Old January 18th, 2005, 11:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Wow, tricky but not impossible.

For the up and down, just create an array that transposes the rows and columns of the 12 original lines. You can then search them the same way you did before.

For the diagonals, you'd have to do some more work but it's still the same. You'd have an array and you'd pick a starting point, say upper left, and assign the elements starting from that point. For a simple 4X4, the assignment would look like this:

A1 B2 C3 D4
B1 C2 D3 E3
C1 D2 E2 F2
D1 E1 F1 G1

So then you'd have an array with String1 = A1; String2 = B1&B2; String3 = C1&C2&C3; etc. At that point, you can search them the normal way, i.e. you can use the function Instr() to find strings within the larger string.

For backward searches, you'd do the same for left-right, up-down, diagonal, but you'd reverse the order of the squares in your arrays FIRST and THEN search. Or better yet, keep the same arrays and reverse the search string only and then look for it in the unreversed arrays.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.