📄 class_book_begin043.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.redLink{ color:red;}
.blueLink{color:blue;}
A{font-size:12pt;text-decoration:none;}
P{font:12pt;line-height:22px;}
h2{font-size:30px;text-align:center;color:rgb(0,144,144);letter-spacing:.5em;font-weight:bold}
.whiteB{color:black;background-color:white;}
.blueB{color:yellow;background-color:blue;}
.blackB{color:white;background-color:black;}
</style>
<title>第四章:按钮</title>
</head>
<script langue="javascript">
<!--
var source;
var flagDU="Up";
var oldClass="";
function ChangeColor(){
source=window.event.srcElement;
if (source.className=="redLink"){
source.className="blueLink";
}
else{
source.className="redLink";
}
}
function moveChangeBack(){
source=window.event.srcElement;
if (source.className==oldClass){oldClass=source.className;
if (flagDU=="Up"){
if (source.className="whiteB"){
source.className="blueB";
}else{
source.className="whiteB";
}
}else{source.className="blackB";
}
}else{//oldClass=source.className;
if (source.className=="whiteB"){
source.className="blueB";
}else{
source.className="whiteB";
}
}
}
function clickChangeBack(){
index01.className="whiteB"
index02.className="whiteB"
source=window.event.srcElement;
source.className="blackB";
flagDU="Down";
oldClass=source.className;
}
function returnValue(){
index01.className="whiteB";
index02.className="whiteB";
flagDU="Up";
}
function getAppVersion()
{
appname= navigator.appName;
appversion = navigator.appVersion;
majorver = appversion.substring(0, 1);
if ( (appname == "Netscape") && ( majorver >= 3 ) ) return 1;
if ( (appname == "Microsoft Internet Explorer") && (majorver>= 4) ) return 1;
return 0;
}
function switchGraphic(num, imgname) {
if (getAppVersion()) {
document[imgname].src = img[num].src;
}
}//-->
</script>
<body>
<script language="javascript">
<!--
imgsrc = new Array();
imgsrc[0] = "images/dot_blank.gif";
imgsrc[1] = "images/dot_filled.gif";
if (getAppVersion())
{
img = new Array();
for (i = 0; i < imgsrc.length; i++)
{
img[i] = new Image();
img[i].src = imgsrc[i];
}
}
//-->
</script>
<div align="center"><center>
<table border="0" cellpadding="8" cellspacing="0" width="100%">
<tr>
<td width="24%" valign="top"><h2><img src="../images/class_img.gif" WIDTH="160" HEIGHT="51"></h2>
<hr size="4" color="#FF0000" width="75%">
<p align="center"><img src="../images/menu_bar_jc_d.gif" WIDTH="150" HEIGHT="35"><img src="../images/dot_blank.gif" name="b1" WIDTH="10" HEIGHT="35"><br>
<a href="../class_api.htm" onMouseOver="switchGraphic('1','b2')" onMouseOut="switchGraphic('0','b2')"><img src="../images/menu_bar_api.gif" border="0" WIDTH="150" HEIGHT="35"></a><img src="../images/dot_blank.gif" name="b2" WIDTH="10" HEIGHT="35"><br>
<span align="center"><a href="../class_wz.htm" onMouseOver="switchGraphic('1','b5')" onMouseOut="switchGraphic('0','b5')"><img src="../images/menu_bar_wz.gif" border="0" WIDTH="150" HEIGHT="35"></a><img src="../images/dot_blank.gif" name="b5" WIDTH="10" HEIGHT="35"></span><br>
<a href="../class_tip.htm" onMouseOver="switchGraphic('1','b3')" onMouseOut="switchGraphic('0','b3')"><img src="../images/menu_bar_tip.gif" border="0" WIDTH="150" HEIGHT="35"></a><img src="../images/dot_blank.gif" name="b3" WIDTH="10" HEIGHT="35"><br>
<a href="../class_fqa.htm" onMouseOver="switchGraphic('1','b4')" onMouseOut="switchGraphic('0','b4')"><img src="../images/menu_bar_end_fqa.gif" border="0" WIDTH="150" HEIGHT="35"></a><img src="../images/dot_blank.gif" name="b4" WIDTH="10" HEIGHT="35"></p>
<p align="center"><a href="../context.htm"><img src="../images/logo_return.jpg" border="0" WIDTH="70" HEIGHT="260"></a></td>
<td width="76%" valign="top" align="center"><div align="center"><center><table border="0" cellpadding="8" cellspacing="0" width="27%" style="background-color: rgb(0,128,128)">
<tr>
<td width="100%" valign="top" align="center"><a name="top"><font size="5" color="#C0C0C0"><strong>VB入门教程</strong></font></a></td>
</tr>
</table>
</center></div><p><a href="class_book_begin041.htm">第一页</a> <a href="class_book_begin042.htm">第二页</a> 第三页 <a href="class_book_begin044.htm">第四页</a><br>
<a href="class_book_begin045.htm">第五页</a> <a href="class_book_begin046.htm">第六页</a>
<a href="class_book_begin047.htm">第七页</a> <a href="../class_book.htm">返回</a>
<br>
</p>
<div align="center"><center><table border="0" cellpadding="8" cellspacing="0" width="100%">
<tr>
<td width="100%"><font size="3" color="#8000FF"><strong><em>第四章:按钮(3)</em></strong></font></td>
</tr>
<tr>
<td width="100%" style="background-color: rgb(232,255,254)"><p ALIGN="JUSTIFY"><strong>下面的例子要更加复杂些,大家一定都用过Windows附件中的计算器,它是一个标准的科学计算器,利用VB我们也可以做到,只是没有那么复杂,四则运算而已。</strong></p>
<p ALIGN="JUSTIFY"><strong>先建立一个新的项目文件,里面包含一个Form1的窗体。然后,添加控件,包括一个Text框(Text1),和17个按钮,这17个按钮使用的名称都是Command1,只是Index属性不同,就好象一个数组,创立一组按钮的方法是,先在窗体上建立一个按钮(Command1),然后在Command1上击鼠标右键,选择复制(Copy),然后在窗体上任意部位击右键,选择粘贴(Paste),系统会提示是否创建控件组,选择“是”,重复上面步骤,直至创立17个按钮为止。各控件属性如下表:</strong></p>
<p ALIGN="JUSTIFY"><img src="0406.gif" alt="04-06.gif (3581 字节)" WIDTH="224" HEIGHT="291"></p>
<table BORDER="1" CELLSPACING="1" CELLPADDING="7" WIDTH="331">
<tr>
<td WIDTH="24%" VALIGN="TOP"><p ALIGN="JUSTIFY"><strong>Text1</strong></td>
<td WIDTH="76%" VALIGN="TOP"><p ALIGN="JUSTIFY"><strong>BackColor=&H00C0FFFF&</strong></p>
<p ALIGN="JUSTIFY"><strong>Text=“0.”</strong></td>
</tr>
<tr>
<td WIDTH="24%" VALIGN="TOP"><p ALIGN="JUSTIFY"><strong>Command1</strong></td>
<td WIDTH="76%" VALIGN="TOP"><p ALIGN="JUSTIFY"><strong>Index 0――16</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 0――9 Caption=“0”-“9”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 10 Caption=“.”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 11 Caption=“=”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 12 Caption=“+”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 13 Caption=“-”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 14 Caption=“×”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 15 Caption=“÷”</strong></p>
<p ALIGN="JUSTIFY"><strong>Index 16 Caption=“清除”</strong></td>
</tr>
</table>
<p ALIGN="JUSTIFY"><strong>如果想改变一些其他的属性,比如字体,可以自己定义一下Font属性,如果相对多个控件的共同属性进行改变,可以在窗体上按下鼠标,拖动,把多个控件一起选定,然后对它们的共同属性进行修改。</strong></p>
<p ALIGN="JUSTIFY"><strong>别看这个东西小,还费了近我两个小时呢,不觉大叹手生,里面也有些地方很绕弯子,我尽量解释清楚。</strong></p>
<p ALIGN="JUSTIFY"><strong>在编写程序之前,我们先来回顾一下计算器的使用。</strong></p>
<ol>
<li><strong>按下数字键在液晶屏上会出现数字,这是最基本的功能。</strong></li>
<li><strong>第一次按下运算键,再按下数字键,将重新输入第二个数字,再次按下运算键,将算出前两个数的结果,然后按下数字键,将又重新输入新的数字。</strong></li>
<li><strong>输入数字后,按下“等于键”将仍输出原来的数字,输入运算符和第二个数字后在按下“等于”,将得到二者的结果。然后又重复第二、三步。</strong></li>
<li><strong>按下“清除”,数据被全部清除。</strong></li>
</ol>
<p ALIGN="JUSTIFY"><strong>了解了这些,我们一步一步实现。</strong></td>
</tr>
</table>
</center></div><p align="right"><strong><a href="#top"><img src="top2.gif" border="0" WIDTH="27" HEIGHT="30"></a></strong></td>
</tr>
</table>
</center></div>
<p> </p>
</body>
</html>
<!--webbot bot="HTMLMarkup" TAG="XBOT" StartSpan --></SCRIPT><!--webbot BOT="HTMLMarkup" endspan -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -