VB教程:形状(Shape)控件
文章作者 100test 发表时间 2007:03:10 18:29:16
来源 100Test.Com百考试题网
14、形状(Shape)控件
作用:可以在Form中显示矩形、圆、椭圆等图形。不能为此控件编写程序代码。
常用属性:
BackStyle:
0——透明的
1——不透明的
Shape:
0——长方形
1——正方形
2——椭圆
3——圆
4——圆角长方形
5——圆角正方形
例子:运动的小球
界面:
主要属性设置: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
[程序演示] [程序下载]