我正在为学校做一个项目,我希望通过动画“太空入侵者”(更大,更小,更大等等)使我的标题页看起来很棒。我一直试图让它工作,但由于某种原因它只是卡住了。
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
textAnimation()
End Sub
Private Sub textAnimation()
Dim bestSize As Integer = 0
If bestSize <= 200 Then
bestSize += 10
ElseIf bestSize >= 500 Then
bestSize -= 10
End If
Textbox1.Font = New Font("Showcard Gothic", bestSize)
End Sub
答案 0 :(得分:0)
你可以用一种非常简单的方式做到这一点!让我告诉你:
全局声明整数bestsize
:
Public Class Form 1
Dim bestsize as integer
然后添加以下内容:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
textAnimation()
End Sub
Private Sub textAnimation()
bestsize = bestsize + 2
If bestsize = 48 then
Timer1.Stop
End If
TextBox1.Font = New Font("Showcard Gothic", bestsize)
End Sub
您可以根据自己的意愿设置bestsize
的增量(您想要非常快或慢地增加大小)。我希望它可以帮助你解决你的问题!
或者为了缩短内存消耗,您可以直接在textAnimation
Sub中编写Timer1_Tick
Sub中编写的语句:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
bestsize = bestsize + 2
If bestsize = 48 then
Timer1.Stop
End If
TextBox1.Font = New Font("Showcard Gothic", bestsize)
End Sub