VB Quiz problem

B

Bryan M

I am trying to create a quiz for one of my classes using PowerPoint in
Windows 2003. I am using one of Shyam's codes he provided on his
website. The problem I am encountring is that I want four choices for
the questions and the code I have only has three choices. Everytime I
try to add the code for a fourth button choice, the quiz will not
begin. Here is the code I have right now.

Sub AssignValues()
SetBulletUnicode "Choice1", UD_CODE_1
SetBulletUnicode "Choice2", UD_CODE_1
SetBulletUnicode "Choice3", UD_CODE_1

Select Case UserAns(QNo - 1)
Case 0
SetBulletUnicode "Choice1", UD_CODE_2
Case 1
SetBulletUnicode "Choice2", UD_CODE_2
Case 2
SetBulletUnicode "Choice3", UD_CODE_2
End Select
With SlideShowWindows(1).Presentation.Slides("QSlide")
.Shapes(1).TextFrame.TextRange.Text = Qs(QNo - 1)
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(QNo - 1,
0)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(QNo - 1,
1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(QNo - 1,
2)
End With
End Sub

Like I said when I add the fourth choice the quiz will not start. If
anyone could help it would be greatly appreciated.
 
D

David M. Marcovitz

It doesn't seem like you have given enough information. This is one
procedure that needs adjusting to add a fourth choice, but other things
need adjusting as well, such as adding a shape and naming it Choice4,
adding a ButtonChoice4 procedure and assigning it to the new shape, ...
Why don't you post all the code you have changed with a comment by each
change you made and list the other things you have done to add the fourth
choice (such as creating and naming new shapes). Otherwise, it will be
difficult to figure out which of the many things you have missed.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
B

Bryan M

It doesn't seem like you have given enough information. This is one
procedure that needs adjusting to add a fourth choice, but other things
need adjusting as well, such as adding a shape and naming it Choice4,
adding a ButtonChoice4 procedure and assigning it to the new shape, ...
Why don't you post all the code you have changed with a comment by each
change you made and list the other things you have done to add the fourth
choice (such as creating and naming new shapes). Otherwise, it will be
difficult to figure out which of the many things you have missed.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_http://www.PowerfulPowerPoint.com/

@x35g2000prf.googlegroups.com:







- Show quoted text -

Here is the entire code.

Const NOOFQS = 6

'Used to manipulated the unicode values of bulleted lists
Const UD_CODE_1 = 111
Const UD_CODE_2 = 8226

Public QNo As Integer
Public ExitFlag As Boolean
Public Qs() As String
Public Choices() As String
Public Ans() As Integer
Public UserAns() As Integer

Sub NextSlide()
' Store the ans for later
'UserAns(QNo - 1) = 1
If QNo < NOOFQS Then
QNo = QNo + 1

SlideShowWindows(1).Presentation.Slides("QSlide").Shapes(1).TextFrame.TextRange.Text
= Qs(QNo - 1)
AssignValues
Else
Call StopQuiz
End If
DoEvents
End Sub
Sub PreviousSlide()
Static X As Integer
If QNo > 1 Then
QNo = QNo - 1
AssignValues
End If
End Sub
Sub StopQuiz(Optional EndType As Boolean = False)
' EndType is used as a boolean Flag to indicate whether the user ran
out of time
' or whether it was normal exit
Dim ScoreCard As Integer
Dim Ctr As Integer
ExitFlag = True
With SlideShowWindows(1)
For Ctr = 0 To NOOFQS - 1
If Ans(Ctr) = UserAns(Ctr) Then ScoreCard = ScoreCard + 1
Next Ctr
If EndType = False Then
.Presentation.Slides("EndSlide").Shapes("Closing").TextFrame.TextRange.Text
= "Your score is : " & ScoreCard & " correct out of " & NOOFQS _
End If
.View.GotoSlide (.Presentation.Slides("EndSlide").SlideIndex)
End With
End Sub




Sub BeginQuiz()
Dim Ctr As Integer
ReDim Qs(NOOFQS)
ReDim Ans(NOOFQS)
ReDim UserAns(NOOFQS)
ReDim Choices(NOOFQS, 6)

' All the questions
Qs(0) = "Question #1" _
& vbCrLf & "Which window on the Home page contains the link for the
Saba Learner Guide?"
Qs(1) = "Question #2" _
& vbCrLf & "If an eLearning course states "Click Here to Access
eLearning" in the title, what section of the Course Details page
contains the link to start the eLearning? "
Qs(2) = "Question #3" _
& vbCrLf & "What window needs to be free of all learning items to show
that you are up-to-date on your training requirements?"
Qs(3) = "Question #4" _
& vbCrLf & "Read & Acknowledge documents are marked complete from the
_______ page?"
Qs(4) = "Question #5" _
& vbCrLf & "To view all of the learning items you have completed, what
text field do you need to delete?"
Qs(5) = "Question #6" _
& vbCrLf & "Which of the following actions CAN be completed from the
Enrollments page?"


' Set all user answers to negative
For Ctr = 0 To NOOFQS - 1
UserAns(Ctr) = -1
Next Ctr

' All the choices 4 each for a question
Choices(0, 0) = " Catalog Search"
Choices(0, 1) = " Current Enrollments"
Choices(0, 2) = " Saba Reference Materials"
Choices(0, 3) = " Certifications"

Choices(1, 0) = " Short Description"
Choices(1, 1) = " Attachments"
Choices(1, 2) = " Title"
Choices(1, 3) = " Prerequisites"

Choices(2, 0) = " Enrollments"
Choices(2, 1) = " Certifications"
Choices(2, 2) = " Curricula"
Choices(2, 3) = " Catalog Search"

Choices(3, 0) = " Enrollments"
Choices(3, 1) = " Transcripts"
Choices(3, 2) = " Curricula"
Choices(3, 3) = " Certifications"

Choices(4, 0) = " Completion Date before"
Choices(4, 1) = " Registration Date"
Choices(4, 2) = " Assigned Date"
Choices(4, 3) = " Completion Date after"

Choices(5, 0) = " Register"
Choices(5, 1) = " Drop"
Choices(5, 2) = " Search"
Choices(5, 3) = " None of the Above"

Ans(0) = 2
Ans(1) = 1
Ans(2) = 1
Ans(3) = 0
Ans(4) = 0
Ans(5) = 1


QNo = 1
AssignValues

With SlideShowWindows(1)
.View.GotoSlide (.Presentation.Slides("QSlide").SlideIndex)
End With

End Sub

Sub SetBulletUnicode(ShapeName As String, Code As Integer)
With
SlideShowWindows(1).Presentation.Slides("QSlide").Shapes(ShapeName).TextFrame.TextRange.ParagraphFormat.Bullet
.UseTextFont = msoTrue
.Character = Code
End With
End Sub
Sub ButtonChoice1()
UserAns(QNo - 1) = 0
AssignValues
End Sub
Sub ButtonChoice2()
UserAns(QNo - 1) = 1
AssignValues
End Sub
Sub ButtonChoice3()
UserAns(QNo - 1) = 2
AssignValues
End Sub
Sub ButtonChoice4()
UserAns(QNo - 1) = 3
AssignValues
End Sub
Sub AssignValues()
SetBulletUnicode "Choice1", UD_CODE_1
SetBulletUnicode "Choice2", UD_CODE_1
SetBulletUnicode "Choice3", UD_CODE_1

Select Case UserAns(QNo - 1)
Case 0
SetBulletUnicode "Choice1", UD_CODE_2
Case 1
SetBulletUnicode "Choice2", UD_CODE_2
Case 2
SetBulletUnicode "Choice3", UD_CODE_2
End Select
With SlideShowWindows(1).Presentation.Slides("QSlide")
.Shapes(1).TextFrame.TextRange.Text = Qs(QNo - 1)
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(QNo - 1,
0)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(QNo - 1,
1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(QNo - 1,
2)
End With
End Sub
Sub ShowAnswers()
Dim AnsList As String
AnsList = "The answers are as follows:" & vbCrLf
For X = 0 To NOOFQS - 1
AnsList = AnsList & Qs(X) & vbTab & " Answer:" & Choices(X,
Ans(X)) & vbCrLf
Next X
MsgBox AnsList, vbOKOnly, "Correct answers"
End Sub
 
D

David M. Marcovitz

It doesn't look like you updated the AssignValues procedure.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
B

Bryan M

It doesn't look like you updated the AssignValues procedure.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_http://www.PowerfulPowerPoint.com/


























- Show quoted text -

That is just it. When I update the AssignValues, nothing works. The
begin Quiz function doesn't work and I can't get to the first
question. Thank you for your help. I really appreciate it.

Here is how I updated it.

Sub AssignValues()
SetBulletUnicode "Choice1", UD_CODE_1
SetBulletUnicode "Choice2", UD_CODE_1
SetBulletUnicode "Choice3", UD_CODE_1
SetBulletUnicode "Choice4", UD_CODE_1

Select Case UserAns(QNo - 1)
Case 0
SetBulletUnicode "Choice1", UD_CODE_2
Case 1
SetBulletUnicode "Choice2", UD_CODE_2
Case 2
SetBulletUnicode "Choice3", UD_CODE_2
Case 3
SetBulletUnicode "Choice4", UD_CODE_2
End Select
With SlideShowWindows(1).Presentation.Slides("QSlide")
.Shapes(1).TextFrame.TextRange.Text = Qs(QNo - 1)
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(QNo - 1,
0)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(QNo - 1,
1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(QNo - 1,
2)
.Shapes("Choice4").TextFrame.TextRange.Text = Choices(QNo - 1,
3)
End With
End Sub
 
S

Shyam Pillai

Bryan,
Do you have the 4th shape on the slide, with the shape name Choice4, to hold
the answer?
You will then need to update the code accordingly across all the segments to
handle this additional answer choice.
for example.

Sub AssignValues()
SetBulletUnicode "Choice1", UD_CODE_1
SetBulletUnicode "Choice2", UD_CODE_1
SetBulletUnicode "Choice3", UD_CODE_1
SetBulletUnicode "Choice4", UD_CODE_1

Select Case UserAns(QNo - 1)
Case 0
SetBulletUnicode "Choice1", UD_CODE_2
Case 1
SetBulletUnicode "Choice2", UD_CODE_2
Case 2
SetBulletUnicode "Choice3", UD_CODE_2
Case 3
SetBulletUnicode "Choice4", UD_CODE_2
End Select
With SlideShowWindows(1).Presentation.Slides("QSlide")
.Shapes(1).TextFrame.TextRange.Text = Qs(QNo - 1)
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(QNo - 1,0)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(QNo - 1,1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(QNo - 1,2)
.Shapes("Choice4").TextFrame.TextRange.Text = Choices(QNo - 1,3)
End With
End Sub

--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 
D

David M. Marcovitz

Now you have listed the code you have changed but what about the details
about what you did to the slides? Getting this to work involves adding
and naming shapes in just the right way.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
B

Bryan M

Now you have listed the code you have changed but what about the details
about what you did to the slides? Getting this to work involves adding
and naming shapes in just the right way.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_http://www.PowerfulPowerPoint.com/









...

read more »- Hide quoted text -

- Show quoted text -

As far as the details go, when I added additional questions,
everything works great. Right now I have six questions and three
choices for each of those questions. The problem arises when I try to
add a fourth choice to all of the questions. I added the
ButtonChoice4 in the code as well as added the the fourth choice in
the Assignvalues. I am guessing my problem is a result from not
adding the correct shape into the quiz.

I copy and paste an existing text box from the quiz and then delete
the information and assign it the ButtonChoice4 macro. Then when I go
to the quiz, I got nothing. The quiz won't advance past the first
slide. I hope that makes sense.

Thanks,
Bryan
 
D

David M. Marcovitz

As far as the details go, when I added additional questions,
everything works great. Right now I have six questions and three
choices for each of those questions. The problem arises when I try to
add a fourth choice to all of the questions. I added the
ButtonChoice4 in the code as well as added the the fourth choice in
the Assignvalues. I am guessing my problem is a result from not
adding the correct shape into the quiz.

I copy and paste an existing text box from the quiz and then delete
the information and assign it the ButtonChoice4 macro. Then when I go
to the quiz, I got nothing. The quiz won't advance past the first
slide. I hope that makes sense.

Thanks,
Bryan

You have to name the shape "Choice4" for the code to work. If you just
copied and pasted choice 3, you will have two buttons named "Choice3" and
that will not allow anything to work (PowerPoint doesn't like two buttons
with the same name). Shyam has code to name shapes on his site, or you
can look at Example 8.7 to get code to name shapes on my site
(http://www.PowerfulPowerPoint.com). Just go to "Examples by Chapter" and
click on "Chapter 8."

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
B

Bryan M

You have to name the shape "Choice4" for the code to work. If you just
copied and pasted choice 3, you will have two buttons named "Choice3" and
that will not allow anything to work (PowerPoint doesn't like two buttons
with the same name). Shyam has code to name shapes on his site, or you
can look at Example 8.7 to get code to name shapes on my site
(http://www.PowerfulPowerPoint.com). Just go to "Examples by Chapter" and
click on "Chapter 8."

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_http://www.PowerfulPowerPoint.com/


Yeah I had been naming it "Choice4" prior with no results. I am think
I am just going to have to try and use a different type of quiz. I
know I am close but I am just at a lose.
 
D

David M. Marcovitz

Yeah I had been naming it "Choice4" prior with no results. I am think
I am just going to have to try and use a different type of quiz. I
know I am close but I am just at a lose.

I assume you didn't put the quotes when you assigned the name.

If your code is not running at all, it is often a compile error that you
can find by going to the Debug menu and choosing Compile VBA Project in the
VBA editor.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

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

Similar Threads

Powerpoint and macros 2
Scrol window 1
Case Statement error 2
The correct answer is 3
macro problem 1
String Array problem in PowerPoint 9

Top