VB每隔一秒字体放大1.3倍,当字体放大到原先的六倍时,开始缩小,每一秒缩小六倍时的1.3倍怎么实现
每隔一秒字体放大1.3倍,当字体放大到原先的六倍时,开始缩小,每隔一秒缩小六倍时的1.3倍,怎么实现,如果循环这个过程,又如何实现,额新手,试了好久一直失败…
答案:Dim a As Long '记录其实大小
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
a = Text1.FontSize
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Text1.FontSize < a * 6 Then
Text1.FontSize = Text1.FontSize * 1.3
Else
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
If Text1.FontSize > a Then
Text1.FontSize = Text1.FontSize / 1.3
Else
Timer2.Enabled = False
Timer1.Enabled = True
End If
End Sub
其他:Dim intSize As Integer
Dim bolSF As Boolean
Private Sub Form_Load()
Me.Timer1.Enabled = True
Me.Timer1.Interval = 1000
intSize = Me.Label1.FontSize
End Sub
Private Sub Timer1_Timer()
If bolSF Then
Me.Label1.FontSize = Me.Label1.FontSize / 1.3
If Me.Label1.FontSize <= intSize Then bolSF = False
Else
Me.Label1.FontSize = Me.Label1.FontSize * 1.3
If Me.Label1.FontSize >= (intSize * 6) Then
bolSF = True
End If
End If
End Sub
【添加一个时钟控件和一个标签】 Dim flag As Boolean
Dim oldsize, size
Private Sub Form_Load()
oldsize = 10
size = 10
flag = True
cnt = 1
End Sub
Private Sub Timer1_Timer()
If flag Then
size = size * 1.3
Label1.FontSize = size
Else
size = size / 1.3
Label1.FontSize = size
End If
If size > (6 * oldsize) Then
flag = Not flag
End If
If size < oldsize Then
flag = Not flag
End If
End Sub Private a As Single
Private Sub Form_Load()
a = Text1.FontSize
Timer1.Interval = 1000
Timer2.Interval = 0
End Sub
Private Sub Timer1_Timer()
If a > Text1.FontSize / 6 Then Text1.FontSize = Text1.FontSize * 1.3: Exit Sub
Timer2.Interval = 1000
Timer1.Interval = 0
End Sub
Private Sub Timer2_Timer()
If a < Text1.FontSize Then Text1.FontSize = Text1.FontSize / 1.3: Exit Sub
Timer1.Interval = 1000
Timer2.Interval = 0
End Sub
上一个:计算机二级VB上机考试,最后一道大题有步骤分吗?
下一个:vb中如何把文本中的矩阵导入并使用