472,801 Members | 1,224 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,801 software developers and data experts.

Combining Two Similar Procedure "Trees"

I have two *very* similar groups of related procedures in my program, and
I'd like to try combining them, but I'm running into one big problem.

Private Sub TileSearchCluster(ByVal PossibleClusterTile1 As HexicTile,
ByVal PossibleClusterTile2 As HexicTile, ByVal PossibleClusterTile3 As
HexicTile)
If Equals(PossibleClusterTile1.Color, PossibleClusterTile2.Color) Then
If Equals(PossibleClusterTile1.Color, PossibleClusterTile3.Color) Then
If TileSearchMode = "Error Checking" Then
TileLabel(a).Text = "X"
TileLabel(b).Text = "X"
TileLabel(c).Text = "X"
ErrorsPresent = True
Exit Sub
End If
End If
End If
End Sub

The PossibleClusterTile variables are members of an array of the form
Tile(1 To 85), which I gathered from TileLabel(1 To 85).BackColor using a
For/Next loop.

Somehow, I need to make TileLabel(a), (b), and (c) reference the indices of
the PossibleClusterTile variables.
Nov 21 '05 #1
2 1004
Confessor <in*****@reply.to.group> wrote in
news:Xn*********************************@130.81.64 .196:
I have two *very* similar groups of related procedures in my program,
and I'd like to try combining them, but I'm running into one big
problem.

Private Sub TileSearchCluster(ByVal PossibleClusterTile1 As HexicTile,
ByVal PossibleClusterTile2 As HexicTile, ByVal PossibleClusterTile3 As
HexicTile)
If Equals(PossibleClusterTile1.Color, PossibleClusterTile2.Color)
Then
If Equals(PossibleClusterTile1.Color, PossibleClusterTile3.Color)
Then
If TileSearchMode = "Error Checking" Then
TileLabel(a).Text = "X"
TileLabel(b).Text = "X"
TileLabel(c).Text = "X"
ErrorsPresent = True
Exit Sub
End If
End If
End If
End Sub

The PossibleClusterTile variables are members of an array of the form
Tile(1 To 85), which I gathered from TileLabel(1 To 85).BackColor
using a For/Next loop.

Somehow, I need to make TileLabel(a), (b), and (c) reference the
indices of the PossibleClusterTile variables.


Just to make my request a bit more coherent:

a, b, and c, used as placeholders for the TileLabel() indices in the code
example above, need to reference the *index* of PossibleClusterTile1, 2,
and 3, respectively.

I've had *some* success with the following:

TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile1)).Text = "X"
TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile2)).Text = "X"
TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile3)).Text = "X"

But, in each case, it only X-es the first label in each group of three...
Nov 21 '05 #2
Confessor <in*****@reply.to.group> wrote in
news:Xn*********************************@130.81.64 .196:
Confessor <in*****@reply.to.group> wrote in
news:Xns95F96F3E658EFinvalidreplytogroup@ 130.81.64.196:
I have two *very* similar groups of related procedures in my program, and I'd like to try combining them, but I'm running into one big problem.

Private Sub TileSearchCluster(ByVal PossibleClusterTile1 As HexicTile, ByVal PossibleClusterTile2 As HexicTile, ByVal PossibleClusterTile3 As HexicTile)
If Equals(PossibleClusterTile1.Color, PossibleClusterTile2.Color) Then
If Equals(PossibleClusterTile1.Color, PossibleClusterTile3.Color) Then
If TileSearchMode = "Error Checking" Then
TileLabel(a).Text = "X"
TileLabel(b).Text = "X"
TileLabel(c).Text = "X"
ErrorsPresent = True
Exit Sub
End If
End If
End If
End Sub

The PossibleClusterTile variables are members of an array of the form Tile(1 To 85), which I gathered from TileLabel(1 To 85).BackColor using a For/Next loop.

Somehow, I need to make TileLabel(a), (b), and (c) reference the indices of the PossibleClusterTile variables.
Just to make my request a bit more coherent:

a, b, and c, used as placeholders for the TileLabel()

indices in the code example above, need to reference the *index* of
PossibleClusterTile1, 2, and 3, respectively.

I've had *some* success with the following:

TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile1)).Text = "X" TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile2)).Text = "X" TileLabel(System.Array.IndexOf(Tile, PossibleClusterTile3)).Text = "X"
But, in each case, it only X-es the first label in each group of three...


I was able to work *around* my problem by changing the
ByVals to ByRefs, allowing me to use/modify a new
Boolean InError variable in my HexicTile structure.

After all possible error-causing scenarios were
checked, I was able to transfer the results back to the
GUI Labels using the following text.

For T = 1 To 85
If Tile(T).InError = True Then
TileLabel(T).Text = "X"
ErrorsPresent = True
End If
Next

This is probably more of a stop-gap measure than an
ideal solution, however, so any suggestions would still
be appreciated.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: delerious | last post by:
I see some code examples like this: <DIV onmouseover="this.style.background='blue'"> and other code examples like this: <DIV onmouseover="javascript:this.style.background='blue'"> Which...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
46
by: TTroy | last post by:
Hi, I'm just wondering why people/books/experts say "the function returns a pointer to.." or "we have to send scanf a pointer to.." instead of "the function returns the address of.." or "we have...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
9
by: Tristán White | last post by:
Hi I am very new to PHP - actually, this is my second day at it, as I've only recently started a new job last week. We're a charity. I have a "No input file selected" problem. A Google search...
3
by: roger.dunham | last post by:
Hi there, I am writing an application that performs calculations on records within a data table. There may be many records in a data table. There are situations where the calculation may not...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.