VB教程:形狀(Shape)控件

字號(hào):

14、形狀(Shape)控件
    作用:可以在Form中顯示矩形、圓、橢圓等圖形。不能為此控件編寫程序代碼。
    常用屬性:
    BackStyle:
    0——透明的
    1——不透明的
    Shape:
    0——長(zhǎng)方形
    1——正方形
    2——橢圓
    3——圓
    4——圓角長(zhǎng)方形
    5——圓角正方形
    例子:運(yùn)動(dòng)的小球
    界面:
    主要屬性設(shè)置:Timer1的Enable為False;Interval為100。Shape1為紅色小球。
    代碼:
    Private Sub Command1_Click()
     If Command1.Caption = "開始" Then
     Timer1.Enabled = True
     Command1.Caption = "停止"
     Else
     Timer1.Enabled = False
     Command1.Caption = "開始"
     End If
    End Sub
    --------------------------------------------------------------------------------
    Private Sub Timer1_Timer()
     Shape1.Left = Shape1.Left + 100
     If Shape1.Left > Form1.Width Then Shape1.Left = 0
    End Sub