multiple conditions must be met before something happens

P

Preschool Mike

I'm trying to design a puzzles (e.g., my design: imagine a 3 x 3 table -
where the table contains 8 pieces of the puzzle. The puzzle type is the kind
where you slide the pieces around until you get the completed image minus the
9th piece. Once all 8 pieces are in their correct spot the ninth piece will
appear). While the code below will make the ninth piece appear once the
other eight have been placed in their correct spot. Because of the type of
puzzle (e.g., constantly moving pieces - a piece can be placed in the correct
spot and then moved out of the correct spot it's possible for the last
picture to appear even when some of the pieces are incorrectly placed -
because they had previously been placed in the correct spot. In short I need
the last piece to only appear when all eight are simotaneously in their
correct spot. Here's what I've got so far. Hope I've been clear enough.

Dim Done1 As Boolean
Dim Done2 As Boolean
Dim Done3 As Boolean
Dim Done4 As Boolean
Dim Done5 As Boolean
Dim Done6 As Boolean
Dim Done7 As Boolean
Dim Done8 As Boolean

Sub MoveTheShapeTo(theAnswerBox As Shape)

MyShapePicture.Top = theAnswerBox.Top + 0
MyShapePicture.Left = theAnswerBox.Left + 0

If MyShapePicture.Name = "A1" And theAnswerBox.Name = "AnswerBox1a" Then
Done1 = True
ElseIf MyShapePicture.Name = "A2" And theAnswerBox.Name = "AnswerBox1b"
Then
Done2 = True
ElseIf MyShapePicture.Name = "A3" And theAnswerBox.Name = "AnswerBox1c"
Then
Done3 = True
ElseIf MyShapePicture.Name = "B1" And theAnswerBox.Name = "AnswerBox2a"
Then
Done 4 = True
ElseIf MyShapePicture.Name = "B2" And theAnswerBox.Name = "AnswerBox2b"
Then
Done5 = True
ElseIf MyShapePicture.Name = "B3" And theAnswerBox.Name = "AnswerBox2c"
Then
Done6 = True
ElseIf MyShapePicture.Name = "C1" And theAnswerBox.Name = "AnswerBox3a"
Then
Done7 = True
ElseIf MyShapePicture.Name = "C2" And theAnswerBox.Name = "AnswerBox3b"
Then
Done8 = True

End If

CheckAnswer

End Sub

Sub CheckAnswer()
If Done1 = True And Done2 = True And Done3 = True And Done4 = True And Done5
= True And _
Done6 = True And Done7 = True And Done8 = True Then
ShowPicture
End If
End Sub

Sub ShowPicture()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("C3").Visible = True
Next

On Error GoTo 0
End Sub

Sub Initialize()
Done1 = False
Done2 = False
Done3 = False
Done4 = False
Done5 = False
Done6 = False
Done7 = False
Done8 = False
ResetPictures
ActivePresentation.SlideShowWindow.View.Next
End Sub
 
D

David Marcovitz

Welcome back, Mike. I think the easiest way to do what you want is
something along the lines of:

If theAnswerBox.Name = "AnswerBox1a" Then
If myShapePicture.Name = "A1" Then
Done1 = True
Else
Done1 = False
End If
ElseIf theAnswerBox.Name = "AnswerBox1b" Then
If myShapePicture.Name = "A2" Then
Done2 = True
Else
Done2 = False
End If
ElseIf ...

That is, first you test to see what box is being answered. Then you test
to see if the answer is correct for that box. If a question gets
answered a second time, it will reset the Done variable for that answer
so that it only takes the last answer.

--David


I'm trying to design a puzzles (e.g., my design: imagine a 3 x 3 table -
where the table contains 8 pieces of the puzzle. The puzzle type is the kind
where you slide the pieces around until you get the completed image minus the
9th piece. Once all 8 pieces are in their correct spot the ninth piece will
appear). While the code below will make the ninth piece appear once the
other eight have been placed in their correct spot. Because of the type of
puzzle (e.g., constantly moving pieces - a piece can be placed in the correct
spot and then moved out of the correct spot it's possible for the last
picture to appear even when some of the pieces are incorrectly placed -
because they had previously been placed in the correct spot. In short I need
the last piece to only appear when all eight are simotaneously in their
correct spot. Here's what I've got so far. Hope I've been clear enough.

Dim Done1 As Boolean
Dim Done2 As Boolean
Dim Done3 As Boolean
Dim Done4 As Boolean
Dim Done5 As Boolean
Dim Done6 As Boolean
Dim Done7 As Boolean
Dim Done8 As Boolean

Sub MoveTheShapeTo(theAnswerBox As Shape)

MyShapePicture.Top = theAnswerBox.Top + 0
MyShapePicture.Left = theAnswerBox.Left + 0

If MyShapePicture.Name = "A1" And theAnswerBox.Name = "AnswerBox1a" Then
Done1 = True
ElseIf MyShapePicture.Name = "A2" And theAnswerBox.Name = "AnswerBox1b"
Then
Done2 = True
ElseIf MyShapePicture.Name = "A3" And theAnswerBox.Name = "AnswerBox1c"
Then
Done3 = True
ElseIf MyShapePicture.Name = "B1" And theAnswerBox.Name = "AnswerBox2a"
Then
Done 4 = True
ElseIf MyShapePicture.Name = "B2" And theAnswerBox.Name = "AnswerBox2b"
Then
Done5 = True
ElseIf MyShapePicture.Name = "B3" And theAnswerBox.Name = "AnswerBox2c"
Then
Done6 = True
ElseIf MyShapePicture.Name = "C1" And theAnswerBox.Name = "AnswerBox3a"
Then
Done7 = True
ElseIf MyShapePicture.Name = "C2" And theAnswerBox.Name = "AnswerBox3b"
Then
Done8 = True

End If

CheckAnswer

End Sub

Sub CheckAnswer()
If Done1 = True And Done2 = True And Done3 = True And Done4 = True And Done5
= True And _
Done6 = True And Done7 = True And Done8 = True Then
ShowPicture
End If
End Sub

Sub ShowPicture()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("C3").Visible = True
Next

On Error GoTo 0
End Sub

Sub Initialize()
Done1 = False
Done2 = False
Done3 = False
Done4 = False
Done5 = False
Done6 = False
Done7 = False
Done8 = False
ResetPictures
ActivePresentation.SlideShowWindow.View.Next
End Sub


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
P

Preschool Mike

What a beautiful thing! Once again David you've been most resourceful. It
works like a charm. I've been racking my brains out all day trying
everything imaginable to get this to work. Guess I could just here after my
first attempt fails but I figure if I did that then I'd never learn from my
mistakes

Thanks again!
 
D

David Marcovitz

What a beautiful thing! Once again David you've been most resourceful. It
works like a charm. I've been racking my brains out all day trying
everything imaginable to get this to work. Guess I could just here after my
first attempt fails but I figure if I did that then I'd never learn from my
mistakes

Thanks again!

Glad I could help.
--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top