VB的几个趣味程序

滚动字幕效果
   当窗体被激活时,字幕会从下往上缓缓上升,像电影字幕效果一样,同时你还可以改变字幕中的文字,滚动速度。
  #2 界面设计
   在窗体中添加一个PictureBox和Timer控件,然后将一个TextBox和滚动条VScrollBox加入到PictureBox中。
   程序如下:
   Private Sub Form_Activate()
   Timer1.Enabled = True
   End Sub
   Private Sub Form_Load()
   Timer1.Interval = 35
   VScroll1.Max = Picture1.Height '将文本框限定在图片框之中滚动
   VScroll1.Min = 0 - Text1.Height
   VScroll1.Value = VScroll1.Max
   End Sub
   Private Sub Text2_LostFocus()
   Text1.Text = Text2.Text
   End Sub
   Private Sub Timer1_Timer()
   If VScroll1.Value > - (Text1.Height - 20) Then '也可用VScroll1.Value >0
   VScroll1.Value = VScroll1.Value - 35
   Else
   VScroll1.Value = VScroll1.Max
   DoEvents
   End If
   Text1.Top = VScroll1.Value
   Text1.Visible = True
   DoEvents
   End Sub
  #1 特殊的退出效果
   当单击窗体上的退出按钮时,窗体不是像一般情况一下就卸载了,而是从下往上逐渐消失,当只剩标题栏时,又改变了卸载方式,开始从右往左直至全部消失。
  #2 界面设计
   在窗体中添加一个CommandButton控件。
   程序如下:
   Private Sub Command1_Click()
   GotoVal = Me.Height / 2
   For Gointo = 1 To GotoVal
   DoEvents
   Me.Height = Me.Height - 10
   If Me.Height <= 11 Then GoTo horiz
   Next Gointo
   horiz
   Me.Height = 30
   GotoVal = Me.Width / 2
   For Gointo = 1 To GotoVal
   DoEvents
   Me.Width = Me.Width - 10
   If Me.Width <= 11 Then End
   Next Gointo
   End
   End Sub
  #1 闪烁的窗体和标签
   这个程序实现了窗体上标签的闪烁效果,这可被用于警告对话框中,使警告闪烁不止,提醒用户注意。
  #2 界面设计
   在窗体中添加一个Timer控件,设置Interval=600,一个Label标签。
   程序如下:
   Private Sub Timer1_Timer()
   If Label1.FontSize = 12 Then
   Label1.ForeColor = &HFF0000 '亮标签
   Label1.FontSize = 14
   Label1.FontBold = False
   Form1.Height = Form1.Height + 100
   Form1.Width = Form1.Width + 100
   Form1.Left = Form1.Left - 50
   Form1.Top = Form1.Top - 50
   Else
   Label1.ForeColor = &H800000 '暗标签
   Label1.FontSize = 12
   Label1.FontBold = True
   Form1.Height = Form1.Height - 100
   Form1.Width = Form1.Width - 100
   Form1.Left = Form1.Left + 50
   Form1.Top = Form1.Top + 50
   End If
   End Sub