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

📄 class_book_begin048.htm

📁 vb实例,很好很好用的哦,处学者的天堂这是第四部分
💻 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.htm">返回</a>&nbsp; <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>第四章:按钮补充</em></strong></font></td>
      </tr>
      <tr>
        <td width="100%" style="background-color: rgb(232,255,254)"><font FACE="宋体" SIZE="3"><p ALIGN="JUSTIFY"><strong>按钮还有两个重要的属性</font><font SIZE="3">Default</font><font FACE="宋体" SIZE="3">(默认属性)和</font><font SIZE="3">Cancel</font><font FACE="宋体" SIZE="3">(取消属性),两个属性都以布尔赋值,把</font><font SIZE="3">Default</font><font FACE="宋体" SIZE="3">设为</font><font SIZE="3">True</font><font FACE="宋体" SIZE="3">,则在按下回车键时,不论焦点处于何处,都会触发该按钮的</font><font SIZE="3">Click</font><font FACE="宋体" SIZE="3">事件,而当</font><font SIZE="3">Cancel</font><font FACE="宋体" SIZE="3">属性被设为</font><font SIZE="3">True</font><font FACE="宋体" SIZE="3">,在按下</font><font SIZE="3">ESC</font><font FACE="宋体" SIZE="3">键时,该按钮的</font><font SIZE="3">Click</font><font FACE="宋体" SIZE="3">属性发生。下面举个例子:</strong></p>
        <p ALIGN="JUSTIFY"><strong>建立一个新窗体和两个按钮,</font><font SIZE="3">Name</font><font FACE="宋体" SIZE="3">属性分别为</font><font SIZE="3">cmdOK</font><font FACE="宋体" SIZE="3">和</font><font SIZE="3">cmdCancel</font><font FACE="宋体" SIZE="3">,把前者的</font><font SIZE="3">Default</font><font FACE="宋体" SIZE="3">设为</font><font SIZE="3">True</font><font FACE="宋体" SIZE="3">,后者的</font><font SIZE="3">Cancel</font><font FACE="宋体" SIZE="3">设为</font><font SIZE="3">True</font><font FACE="宋体" SIZE="3">,</font><font SIZE="3">Caption</font><font FACE="宋体" SIZE="3">属性分别为</font><font SIZE="3">OK</font><font FACE="宋体" SIZE="3">和</font><font SIZE="3">Cancel</font><font FACE="宋体" SIZE="3">。如图</font><font SIZE="3">4</font><font FACE="宋体" SIZE="3">-</font><font SIZE="3">8</font><font FACE="宋体" SIZE="3">。填写代码后运行:</font></strong><font SIZE="3"></p>
        <p ALIGN="JUSTIFY"><img src="0408.gif" alt="04-08.gif (2154 字节)" WIDTH="318" HEIGHT="238"></p>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>Private Sub cmdCancel_Click()</strong></font></p>
        <blockquote>
          <p ALIGN="JUSTIFY"><strong><font color="#004080" SIZE="3">MsgBox &quot;Cancel</font><font color="#004080"><font FACE="宋体" SIZE="3">按钮被按下</font>&quot;, 
          vbDefaultButton1, &quot;<font FACE="宋体" SIZE="3">提示</font></font><font color="#004080" SIZE="3">&quot;</font></strong></p>
        </blockquote>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>End Sub</strong></font></p>
        <p ALIGN="JUSTIFY"> </p>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>Private Sub cmdOK_Click()</strong></font></p>
        <blockquote>
          <p ALIGN="JUSTIFY"><strong><font color="#004080" SIZE="3">MsgBox &quot;OK</font><font color="#004080"><font FACE="宋体" SIZE="3">按钮被按下</font>&quot;, 
          vbDefaultButton1, &quot;<font FACE="宋体" SIZE="3">提示</font></font><font color="#004080" SIZE="3">&quot;</font></strong></p>
        </blockquote>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>End Sub</strong></font></font><font FACE="宋体" SIZE="3"></p>
        <p ALIGN="JUSTIFY"><strong>结果如图</font><font SIZE="3">4</font><font FACE="宋体" SIZE="3">-</font><font SIZE="3">9</font><font FACE="宋体" SIZE="3">、</font><font SIZE="3">4</font><font FACE="宋体" SIZE="3">-</font><font SIZE="3">10</font><font FACE="宋体" SIZE="3">:</strong></p>
        <p ALIGN="JUSTIFY"><img src="0409.gif" alt="04-09.gif (901 字节)" WIDTH="104" HEIGHT="96"><img src="0410.gif" alt="04-10.gif (977 字节)" WIDTH="125" HEIGHT="96"></p>
        <p ALIGN="JUSTIFY"><strong>快捷键大家一定都知道,在</font><font SIZE="3">VB</font><font FACE="宋体" SIZE="3">如何实现呢。其实很简单,在刚才的例子里在建立一个按钮</font><font SIZE="3">Command1</font><font FACE="宋体" SIZE="3">,把它的</font><font SIZE="3">Caption</font><font FACE="宋体" SIZE="3">属性设为</font><font SIZE="3">Click &amp;ME</font><font FACE="宋体" SIZE="3">,如图</font><font SIZE="3">4</font><font FACE="宋体" SIZE="3">-</font><font SIZE="3">11</font><font FACE="宋体" SIZE="3">,在</font><font SIZE="3">M</font><font FACE="宋体" SIZE="3">的下面有一条下划线,运行程序,当你按下</font><font SIZE="3">Alt+M</font><font FACE="宋体" SIZE="3">的时候就触发了</font><font SIZE="3">Command1_Click</font><font FACE="宋体" SIZE="3">事件:</font></strong><font SIZE="3"></p>
        <p ALIGN="JUSTIFY"><img src="0411.gif" alt="04-11.gif (270 字节)" WIDTH="81" HEIGHT="33"></p>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>Private Sub Command1_Click()</strong></font></p>
        <blockquote>
          <p ALIGN="JUSTIFY"><font color="#004080"><strong>MsgBox &quot;Click ME <font FACE="宋体" SIZE="3">按钮被按下</font>&quot;, vbDefaultButton1, &quot;<font FACE="宋体" SIZE="3">提示</font>&quot;</strong></font></p>
        </blockquote>
        <p ALIGN="JUSTIFY"><font color="#004080"><strong>End Sub</strong></font></font><font FACE="宋体" SIZE="3"></p>
        <p ALIGN="JUSTIFY"><strong>据我所知,有许多用户有使用快捷键的习惯,注意细节上的问题能够使将来你的程序得到更多人的欣赏,不是吗?</strong></font></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 + -