第十章  其他常用语句及控件
双击滚屏  关闭窗口

 

10.1 框架 (Frame)



VB 中的控件分为两类:一是标准控件,二是 ActiveX 控件。

默认情况下工具箱中只有标准控件,用户也可通过 “ 工程 ” 菜单中的 “ 部件 ” 命令添加所需的 ActiveX 控件。

10.1 框架 (Frame)

1. 框架的用途

作为容器放置其他控件对象,将这些控件对象分成可标识的控件组;框架内的所有控件将随框架一起移动、显示和消失。

( 框架示例: “ 幻灯片放映 ” → “ 设置放映方式 ” 对话框 )

例 10.1 控制文本的字体、字号及颜色

           
(1) 在窗体上设置 3 个框架 Frame1 、 Frame2 和 Frame3

 

(2) 编写程序代码

功能要求:在三个框架中分别选择字体、字号和颜色,单击 “ 确定 ” 按钮后,文本框中的文本相应属性会发生变化

Private Sub Form_Load()

Option1.Value = True

Option3.Value = True

Option5.Value = True

Text1.FontName = " 宋体 "

Text1.FontSize = 16

Text1.ForeColor = RGB(0, 0, 255)

End Sub

Private Sub Command1_Click() ‘“ 确定 " 按钮单击事件

If Option1.Value Then

Text1.FontName = " 宋体 "

Else

Text1.FontName = " 幼圆 "

End If

If Option3.Value Then

Text1.FontSize = 16

Else

Text1.FontSize = 20

End If

If Option5.Value Then

Text1.ForeColor = RGB(0, 0, 255)

Else

Text1.ForeColor = RGB(255, 0, 0)

End If

End Sub

 
双击滚屏  关闭窗口
 
版权所有数学与信息科学学院