PDA

View Full Version : Variable from procedure to use in a sub



Fred.Peters
10-19-2020, 08:08 PM
I want the procedure to select a random slide and pass it to a sub and as the show goes through the slides, it identifies the said slide.
MS Powerpoint 2019
Windows 10 home
screenshot attached

The order shown is my best attempt at showing the variable which changes on each slide.



I have a procedure that selects a random slide.
I have assigned that result a variable and then tried to use it in a sub that identifies slides but the variable WILL NOT remain the same through the slide show, which I need to happen.

I am using message boxes to show the values and have tried umpteen different ways and locations for msgBox's


Code is CURRENTLY as follows.
__________________________________________________________________

Public Function randomSlideNumber() As Integer


Dim index
Static intDJ As Integer
Dim targetValues(1 To 29) As Integer


targetValues(1) = 1
targetValues(2) = 2
targetValues(3) = 3
targetValues(4) = 4
targetValues(5) = 5

index = Int(5 * Rnd + 1)


randomSlideNumber = targetValues(index)
intDJ = randomSlideNumber
MsgBox ("Double Jeopary Slide Number is " & intDJ)

End Function

______________________________________________________________

Public Sub OnSlideShowPageChange()


Dim i As Integer
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
If i = 3 Then
Exit Sub
Else
Dim intDJ As Integer
intDJ = randomSlideNumber


End If
MsgBox ("Slide No: " & i & Chr(13) _
& " intDJ: " & intDJ)


End Sub


thank you in advance