Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple for and next loops

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
0
0
GB
I have 12 squares, 6 named block and 6 named blockgot.

When a block visibility is false I want a blockgot's visibility to be true.

so far I have this :
the block part works, but the blockgot only hides one block on load ?


sub timer1

For i = 0 To 6
If block(i).Visible = True Then
If mozzy.Left < block(i).Left + block(i).Width And mozzy.Left + mozzy.Width > block(i).Left And mozzy.Top < block(i).Top + block(i).Height And mozzy.Top + mozzy.Height > block(i).Top Then
block(i).Visible = False
End If
End If


For a = 0 To 6
If block(i).Visible = False Then
blockgot(a).Visible = True
End If

Next a
Next i



end sub

Sub Form_Load()

block(i).Visible = True
blockgot(a).Visible = False

End Sub

can anybody give me some tips ?

cheers.
 
look at your code and what it is doing

timer code first
for i = 0 to 6
if block(0).visible = true then do this test
if passes test then block(0) visible = false
end if
For a = 0 To 6
If block(0).Visible = False Then blockgot(0).Visible = True
End If
next a
If block(1).Visible = False Then blockgot(1).Visible = True
etc etc
If block(6).Visible = False Then blockgot(6).Visible = True
next i
if block(1).visible = true then do this test
end if
For a = 0 To 6
If block(0).Visible = False Then blockgot(0).Visible = True
End If
next a
If block(1).Visible = False Then blockgot(1).Visible = True
etc etc
If block(6).Visible = False Then blockgot(6).Visible = True
and it continue to loop till it has check all the boxes 7 times

I think the problem is when you load only the first blocks
get set.

Sub Form_Load()
block(i).Visible = True 'i = nothing so block(0).visible = true
blockgot(a).Visible = False ' blockgot(0).visible = false
End Sub

I think what you want to do is

Sub Form_Load()
for a = 0 to 5 'you say there are 12 squares so 0,1,2,3,4,5 = count of 6
block(a).Visible = True
blockgot(a).Visible = False
next a
end sub

then it will loop thru each one set it to visible or not

Hopefully I got a grasp on what you were attempting to do.
good luck

 
Just a quick comment, For i = 0-6 is really a 7 count loop. Is your array a base(0) or base(1)? Dan Grogan
dan@siqual.com

&quot;Absit prudentia nil rei publicae profitur.&quot;
Without common sense you ain't gonna have nothing.
 
sub timer1

For i = 0 To 5
If block(i).Visible = True Then
If mozzy.Left < block(i).Left + block(i).Width And mozzy.Left + mozzy.Width > block(i).Left And mozzy.Top < block(i).Top + block(i).Height And mozzy.Top + mozzy.Height > block(i).Top Then
block(i).Visible = False
End If
End If
'#######################################
If block(i).Visible = False Then
blockgot(i).Visible = True
end if
'#######################Or, if you also want blockgot(i) NOT Vis when block(i) IS vis, Then below(no if statement)################################################
blockgot(i).Visible = NOT block(i).Visible
'###################################
Next i
end sub


Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top