看了一个关于找错的游戏用ppt做的,模块里面有部分代码看不懂

xiaobao89 2014-04-27 02:50:06
模块里的代码,我下载的是pps格式的给转换成了ppt!
问题1:发现宏里面有对应下面的函数的宏文件,不知道啥意思?能不能把宏文件删除,如果不能删除这些个宏文件怎么来的
问题2:类似于 Set myDocument = ActivePresentation.Slides(2) 中的Slides(2)里面的2代表谁?
哪里有详细描述.Shapes("score").TextFrame.TextRange.Text 这些语句的基本文档之类的,头大啊
我的本意是实现计分器,用vba控件能实现,但是我想加分的时候显示+10,各种不会!
下面是人家的语句,实现的是找不同功能,找对了就+分,哪里显示的是?我怎么移植到我的语句里?是否我也得建一个模块,然后调用。
Public stp As Integer
Dim s As Integer, last As Integer
Public finish As Integer
Dim flag(16) As Boolean
Private Sub play(ByVal n As String, ByVal nn As String)
stp = 0
Dim i As Integer
Dim name As String

Set myDocument = ActivePresentation.Slides(2)

With myDocument
If Val(n) > 8 Then
name = Val(n) + 8
.Shapes(n).Visible = msoFalse
.Shapes(name).Visible = True
flag(Val(nn)) = False

Else
.Shapes(nn).Visible = msoFalse
.Shapes(n).Visible = msoFalse
End If

.Shapes("text").Top = .Shapes(n).Top ' - Shapes(n).Height '/ 2
.Shapes("text").Left = .Shapes(n).Left ' + 5
.Shapes("text").Visible = msoTrue
Call dely
For i = 1 To 8
.Shapes("text").IncrementTop -5
Call dely
Next
.Shapes("text").Visible = msoFalse
s = s + 10
finish = finish - 1
.Shapes("score").TextFrame.TextRange.Text = s
.Shapes("diff").TextFrame.TextRange.Text = finish
If (finish = 0) Then
Call MoveSlide
End If
End With
End Sub
Sub initial(ByVal B As Boolean, BB As Boolean)
Dim i As Integer
Dim name As String
Dim finish As Integer
With ActivePresentation.Slides(2)
For i = 1 To 16
name = i
.Shapes(name).Visible = B
flag(i) = B
Next
For j = 17 To 24
name = j
.Shapes(name).Visible = BB
Next
.Shapes("text").Visible = msoFalse
.Shapes("text1").Visible = msoFalse
.Shapes("score").TextFrame.TextRange.Text = Str(s)
finish = 8
.Shapes("diff").TextFrame.TextRange.Text = finish
.Shapes("page").TextFrame.TextRange.Text = last + 1

End With
End Sub
Sub p0()
Dim i As Integer
stp = 0
With ActivePresentation.Slides(2)
.Shapes("text1").Top = 200
.Shapes("text1").Left = 300
.Shapes("text1").Visible = msoTrue
Call dely
For i = 1 To 8
.Shapes("text1").IncrementTop -5
Call dely
Next
.Shapes("text1").Visible = msoFalse
s = s - 5
.Shapes("score").TextFrame.TextRange.Text = Str(s)
End With
End Sub
Sub p1()
If flag(1) = True Then Call play(1, 9) Else Call p0
End Sub
Sub p2()
If flag(2) = True Then Call play(2, 10) Else Call p0
End Sub
Sub p3()
If flag(3) = True Then Call play(3, 11) Else Call p0
End Sub
Sub p4()
If flag(4) = True Then Call play(4, 12) Else Call p0
End Sub
Sub p5()
If flag(5) = True Then Call play(5, 13) Else Call p0
End Sub
Sub p6()
If flag(6) = True Then Call play(6, 14) Else Call p0
End Sub
Sub p7()
If flag(7) = True Then Call play(7, 15) Else Call p0
End Sub
Sub p8()
If flag(8) = True Then Call play(8, 16) Else Call p0
End Sub
Sub p9()
If flag(9) = True Then Call play(9, 1) Else Call p0
End Sub
Sub p10()
If flag(10) = True Then Call play(10, 2) Else Call p0
End Sub
Sub p11()
If flag(11) = True Then Call play(11, 3) Else Call p0
End Sub
Sub p12()
If flag(12) = True Then Call play(12, 4) Else Call p0
End Sub
Sub p13()
If flag(13) = True Then Call play(13, 5) Else Call p0
End Sub
Sub p14()
If flag(14) = True Then Call play(14, 6) Else Call p0
End Sub
Sub p15()
If flag(15) = True Then Call play(15, 7) Else Call p0
End Sub
Sub p16()
If flag(16) = True Then Call play(16, 8) Else Call p0
End Sub
Sub go()
s = 0
finish = 8
last = 0
Call initial(True, False)
Application.SlideShowWindows(1).View.GotoSlide 2
End Sub
Sub MoveSlide()
With ActivePresentation
last = last + 1
.Slides(3).MoveTo topos:=2
Call initial(True, False)
.Slides(4).MoveTo topos:=3
Call initial(True, False)
End With
finish = 8
With Application.SlideShowWindows(1).View
If last < 3 Then
.GotoSlide 2
Else
ActivePresentation.Slides(5).Shapes("score").TextFrame.TextRange.Text = Str(s)
.GotoSlide 5
End If
End With
End Sub
Sub gamesover()
Call initial(True, False)
stp = 1
With Application
.ActivePresentation.Saved = msoFalse
.Quit
End With
End Sub
Sub game_end()
Application.SlideShowWindows(1).View.GotoSlide 6
End Sub
Sub dely()
DoEvents
If stp = 1 Then End
End Sub
...全文
206 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaobao89 2014-04-27
  • 打赏
  • 举报
回复
这个是ppt里的 vba 代码 vb的不要
xiaobao89 2014-04-27
  • 打赏
  • 举报
回复
例如:这句是不是代表显示一个文本框 ? 我的操作,新建ppt,新建命令按钮 Private Sub CommandButton1_Click() With ActivePresentation.Slides(1) .Shapes("text1").Top = 200 .Shapes("text1").Left = 300 .Shapes("text1").Visible = msoFalse End With End Sub 我运行了下,不行,未找到制定名称的项目!

2,089

社区成员

发帖
与我相关
我的任务
社区描述
在线培训学习经验交流分享、优质课程资源共享。
社区管理员
  • IT课程大本营社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧