Performing calculations with random numbers

I'm trying to make a math checkpoint where students are presented with random problems with adding numbers with numbers 1-20. I worked on the tutorials of David Markovtis (and others) and used his code as a starting point. Since my audience is young students, I would like problems with mathematics not to be in the message box, but in the form of text fields or forms that I can customize and make large and visually attractive to young students.

So what I want to do ... In the Powerpoint show

  • The student can press the start button to advance to the next slide.
  • The next slide automatically generates 2 random numbers that the student must add together.
  • Student responding
  • If the answer is correct - I would like something to mean that the answer was correct, but not what they need to click to close. Ideally, a small star flares up in a corner and then disappears.
  • If the answer is incorrect, the message or image blinks and disappears.

  • A new problem with the addition is created automatically / randomly. I would like to set the number of additional problems, for example. 20, then slide the slide onto a sliding slide that shows their rating in photos, for example. star for every correct answer.

Update: Using Activex Text Fields:

I had success with activex text fields in being able to randomly display two numbers and multiply them and display the answer in the third activex text box, which I hid from the slide. I used the fourth as an input box for students to enter their answer. If this is the same as the answer in the third field, I can show the star and clear the fields, and then go to the next slide. If this is not the same, I can go show another image and then go to the next slide. (I initially wanted the slide to be updated and use one slide to ask 20 questions, but found it difficult.)

Currently, this requires clicking three commands.

What I have supported so far (I know it will seem sad and possibly unstable to you, but a significant achievement for me and the “bit” works) I can control it for multiplication but when I + values, for example 9 + 3 I get 93

Private Sub CommandButton1_Click() TextBox1.Value = Int(10 * Rnd) TextBox2.Value = Int(10 * Rnd) TextBox3.Value = TextBox1.Value * TextBox2.Value End Sub Private Sub CommandButton2_Click() If TextBox4.Value = TextBox3.Value Then ActivePresentation.Slides("problem").Shapes("badge5").Visible = True ActivePresentation.Slides("score").Shapes("badge5").Visible = True Else ActivePresentation.Slides("problem" _).Shapes("incorrect").Visible = True TextBox1.Value = "" TextBox2.Value = "" TextBox3.Value = "" TextBox4.Value = "" End If End Sub Private Sub CommandButton3_Click() SlideShowWindows(1).View.Next End Sub 

What I need

I would like the random numbers in command button 1 to be activated automatically.

I would like to combine command button 2 and 3 and turn on the wait time after the appearance of an asterisk or irregular shapes before moving on to the next slide, but the code I found applies the wait time to the whole sequence, since I’m not sure how to turn it on .

 Private Sub Time_Click() iTime = 2# Start = Timer While Timer < Start + iTime Wend With SlideShowWindows(1).View.Next End With End Sub 

Using shapes: I would prefer to work with regular text fields or shapes, but ... I managed to create random numbers in the shapes, but they could not multiply them in students in the activex text box, which determines whether it is correct or incorrect. I think the problem is trying to use both forms and the activex text box.

I would like to use the shapes because I would like to create master slide layouts that can be selected using the following code - although this is not an interruption to the transaction.

 Sub background() ActivePresentation.Slides.Range(Array(2, 3, 4, 5)).CustomLayout_ = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(6) End Sub 

I feel that this is something that other teachers can use, and I am happy to publish my finished show if someone wants and can help with coding. I really appreciate the tolerance and patience of participants shown to people like me, who first jumped into the head, are excited and lost it, but are struggling.

+7
vba random powerpoint-vba
source share
1 answer

So, in order to break up the pieces you requested in the “What do I need” section, I will analyze my answer into two sections:

"I would like random numbers in command button 1 to be activated automatically."

I assume that you mean "automatically" that you want the "next" slide to be automatically populated with values ​​after the user answered the question on the previous slide. To execute this function, I would call a method that currently calls CommandButton1 after all the logic in CommandButton2 has been run.

"I would like to combine teams 2 and 3 and turn on the wait time after the appearance of an asterisk or irregular shapes before moving on to the next slide ..."

I would simply combine the code of two functions with the wait function between two bits of code. I'm not sure where you found the code you sent for the Timer_Click function, I don't think this will work at the moment. I usually used the "wait" method mentioned in this.

The result, after changing the code for the two new requirements, will be something like this:

 Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub CommandButton2_Click() 'Command Button 2(code) If TextBox4.value = TextBox3.value Then ActivePresentation.slides("problem").Shapes("badge5").visible = True ActivePresentation.slides("score").Shapes("badge5").visible = True Else ActivePresentation.slides("problem").Shapes("incorrect").visible = True TextBox1.value = "" TextBox2.value = "" TextBox3.value = "" TextBox4.value = "" End If 'Wait code here(1000ms) Sleep 1000 'Command Button 3(code) SlideShowWindows(1).View.Next 'Call the command for CommandButton1, 'this will "automatically" populate the slide with new values CommandButton1_Click End Sub 
+1
source share

All Articles