如上

解决方案 »

  1.   

    窗体的Cls方法是VB提供的清屏方法,但使用该方法来清屏不能实现我们希望的动态效果。实际上,所谓清屏就是用一种颜色将屏幕上原来的内容覆盖掉。那么,就可以使用图形方法(Line、Circle等)在窗体上绘制线条来清屏。通过控制线条的绘制过程,就可以实现五彩缤纷的清屏效果。例如,从窗体的两边开始画直线,使它们同时向中间靠拢,即可产生闭幕的清屏效果
    '设置清屏色
    Dim bcolor
    Private Sub Clscolor()
        Randomize
        bcolor = RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
    End Sub
        '从左右两边到中间清屏
        Private Sub ClrScrl()
            Dim i As Integer
            Clscolor
            For i = 0 To ScaleWidth / 2
                Line (i, 0)-(i, ScaleHeight), bcolor
                Line (ScaleWidth - i, 0)-(ScaleWidth - i, ScaleHeight), bcolor
            Next i
        End Sub
        '从中间到左右两边清屏
        Private Sub ClrScr2()
            Dim i As Integer
            Clscolor
            For i = ScaleWidth / 2 To 0 Step -1
                Line (i, 0)-(i, ScaleHeight - 1), bcolor
                Line (ScaleWidth - i, 0)-(ScaleWidth - i, ScaleHeight), bcolor
            Next i
        End Sub
        '从上(顶)下(低)到中间清屏
        Private Sub ClrScr3()
            Dim i As Integer
            Clscolor
            For i = 0 To ScaleHeight / 2
                Line (0, i)-(ScaleWidth, i), bcolor
                Line (0, ScaleHeight - i)-(ScaleWidth, ScaleHeight - i), bcolor
            Next i
        End Sub
        '从中间到上(顶)下(底)清屏
        Private Sub ClrScr4()
            Dim i As Integer
            Clscolor
            For i = ScaleHeight / 2 To 0 Step -1
                Line (0, i)-(ScaleWidth, i), bcolor
                Line (0, ScaleHeight - i)-(ScaleWidth, ScaleHeight - i), bcolor
            Next i
        End Sub
        '菱形清屏,从四角向中心
        Private Sub ClrScr5()
            Dim i, j As Integer
            Clscolor
            For i = 0 To ScaleWidth Step 200
                For j = 0 To ScaleHeight Step 200 * ScaleHeight / ScaleWidth
                    Line (i, 0)-(0, j), bcolor
                    Line (ScaleWidth - i, ScaleHeight)-(ScaleWidth, ScaleHeight - j), bcolor
                    Line (0, ScaleHeight - j)-(i, ScaleHeight), bcolor
                    Line (ScaleWidth - i, 0)-(ScaleWidth, ScaleHeight - j), bcolor
                Next j
            Next i
        End Sub
        '圆形清屏,由大至小从外围向中心
        Private Sub ClrScr6()
            Dim i As Integer
            Clscolor
            For i = ScaleWidth To 0 Step -3
            Circle (ScaleWidth / 2, ScaleHeight / 2), i / 2, bcolor
            Next i
        End Sub
        '圆形清屏,由小至大从中心向外围
        Private Sub ClrScr7()
            Dim i As Integer
            Clscolor
            For i = 0 To ScaleHeight Step 3
            Circle (ScaleWidth / 2, ScaleHeight / 2), i / 2, bcolor
            Next i
        End SubPrivate Sub Command1_Click()
        ClrScr7
        ClrScr6
        ClrScr5
        ClrScr4
        ClrScr3
        ClrScr2
        ClrScrl
    End Sub欢迎光临电脑爱好者论坛 bbs.cfanclub.net  
      

  2.   

    www.vbgood.com在代码天地和经验之谈中用“百叶窗”搜索一下