VB教程:形状(Shape)控件 |
|
www.nanhushi.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
[程序演示] [程序下载]
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: VB教程:记时器(Timer) 下一篇文章: VB考试教程:OLE控件 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|