⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 控件-单选按钮.htm

📁 几种VB程序和案例
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>控件-单选按钮</title>
</head>

<body bgcolor="#CCFFFF" vlink="#0000FF">

<p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FF0000"><font face="华文彩云" size="6">VB程序设计基础</font></font></p>
<p align="left" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><br>
<font color="#0000FF">七、单选按钮</font><br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">单选</font>按钮Option 用于<font color="#800000">单项选择</font>,一组选项中只能选定<font color="#800000">一个</font>,代码是Option1.Value=(0,1)<br> 
&nbsp;&nbsp;&nbsp; <font color="#0000FF">启动</font>VB、设置好窗体的Caption为“<font color="#800000">单选按钮</font>”以及背景色、图标,找到最后一个属性“<font color="#800000">WindowState</font>”改为2-Maximized,添加一个标签Label,将Caption改为“我的单选按钮”,以“<font color="#800000">单选按钮</font>”(或MyOption)为文件名,<font color="#800000">保存文件到自己的文件夹</font>中。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">将</font>工作区中的窗体窗口<font color="#800000">最大化</font>占满中间区域,我们要多放一些控件在里头。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">先</font>找到工具箱第三行的一个标有<font color="#800000">XY</font>的方框,这是框架,用来<font color="#800000">分组</font>的,选中框架,在窗体<font color="#800000">左侧</font>画一个,修改它的Caption属性为“<font color="#800000">姓名</font>”这一组是姓名,修改<font color="#800000">提示</font>为“这是第一个框架”。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">再</font>选择单选按钮,一个中间有<font color="#800000">黑点</font>的小圆,在第四行上,再在窗体的<font color="#800000">框架里</font>面画一个单选按钮(<font color="#800000">注意</font>画在框架里面),修改它的Caption为<font color="#800000">自己的</font>名字。同样在添加两个单选按钮到框架里面,分别修改它的Caption为自己<font color="#800000">左右</font>同桌的姓名。按住Ctrl键<font color="#800000">不松手</font>,同时选中三个单选按钮,然后在“<font color="#800000">格式</font>”菜单中找到“<font color="#800000">统一尺寸</font>”中的“<font color="#800000">两者都相同</font>” ,再找到“格式”菜单中的“<font color="#800000">对齐</font>”里的“左对齐”,再找到“格式”菜单中的“<font color="#800000">垂直间距</font>”里的“相同间距”把三个单选按钮排列整齐。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">好</font>,看一下姓名框架和单选按钮,<font color="#800000">检查</font>一下各个属性和大小颜色,调整到最合适。<font color="#800000">保存一下文件</font><br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">运行</font>一下程序,在各个名字上点一下,看看选择的情况,你能不能<font color="#800000">同时</font>选中两个人名?<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">关闭</font>程序,回到窗体中,再加入一个<font color="#800000">框架</font>,修改Caption为“<font color="#800000">性别</font>”,提示为“这是第二个框架”,添加两个单选按钮到里面,把<font color="#800000">Caption</font>改成什么呢?当然是“男”和“女”,同样在“<font color="#800000">格式</font>”菜单中调整好尺寸和对齐,再选中“<font color="#800000">男</font>”按钮,在属性窗口找到<font color="#800000">Value</font>,在右边选择“True”,这是什么意思?<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">单击</font>“启动”,看一下“性别”框架,有什么不同吗?在“男”按钮上有一个黑点,也就是<font color="#800000">默认选中</font>了男性性别。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">关闭</font>程序回到窗体窗口,再添加一个<font color="#800000">框架</font>,修改Caption为“<font color="#800000">爱好</font>”,提示为“这是第三个框架”,向框架里面添加三个<font color="#800000">复选框</font>,为什么不用单选按钮呢?因为这儿是<font color="#800000">多项选择</font>,所以要用复选框。修改Caption为“音乐”、“美术”、“体育”,选中音乐复选框,在属性窗口中找到<font color="#800000">Value</font>,在右边选择“<font color="#800000">1-checked</font>”也就是默认打勾。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">检查</font>一下各个对象的标题、大小、颜色,调整到<font color="#800000">最佳</font>的状态。<font color="#800000">保存一下程序</font><br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">启动</font>程序,看一下我们的程序,一个整齐而又大方的窗口,在各个<font color="#800000">按钮上</font>点一下,测试一下是否能够正确的<font color="#800000">响应</font>。<br>
&nbsp;&nbsp;&nbsp; <font color="#0000FF">本节</font>学习了框架和单选按钮的使用,下一节我们将为程序添加代码。&nbsp;&nbsp;&nbsp;<font color="#800000"><br> 
</font> 
&nbsp;&nbsp;&nbsp; <a href="单飞.exe">单人飞行</a> <font size="2">(在弹出的对话框中选择“<font color="#800000">在当前位置运行该程序</font>”和“<font color="#800000">是</font>”)</font></p>       
                     
                      
<font SIZE="1" COLOR="#000000">      
<p style="line-height: 200%; margin-top: 2; margin-bottom: 0">本教程由86团学校TeliuTe制作|著作权所有,不得用于商业用途</p>      
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">美丽的校园……</p>      
</font>            
                   
                    
</body>     
     
</html>     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -