随机名称选择器,Powerpoint中没有重复项

时间:2018-06-03 06:48:33

标签: random

我的powerpoint幻灯片中有以下代码。它将从1到10随机化一个数字并将其显示在一个框中。但它将继续重复数字。我怎样才能阻止重复?我应该插入什么代码?感谢...

Sub UpdateRandomNumber(oSh As Shape)
Dim X As Long
'Make the shape’s text a random number
'X or less
'Change 12 below to any number you’d like:
X = 10

oSh.TextFrame.TextRange.Text = CStr(Random(X)

)

'Now force PPT to go to the slide again (ie, to redraw it) so that
'the changed text appears:
SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex)

End Sub

Function Random(High As Long) As Long
'Generates a random number less than or equal to
'the value passed in High
Randomize
Random = Int((High * Rnd))
End Function

0 个答案:

没有答案