471,319 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 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 952
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by delerious | last post: by
205 posts views Thread by Jeremy Siek | last post: by
46 posts views Thread by TTroy | last post: by
21 posts views Thread by Helge Jensen | last post: by

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.