📄 class_book_begin031.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>第三章:VB语言</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_begin032.htm">第二页</a> <a href="class_book_begin033.htm">第三页</a> <a href="class_book_begin034.htm">第四页</a>
<a href="../class_book.htm">返回</a></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>第三章:VB语言(1)</em></strong></font></td>
</tr>
<tr>
<td width="100%" style="background-color: rgb(232,255,254)"><p ALIGN="JUSTIFY"><strong><span style="line-height: 24px"><font color="#004080">本章提要:</font></span></strong></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%" msimagelist>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">VB语法与Basic的异同</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">注释语句</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">长语句的分行</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">条件语句</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">循环语句</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">运算操作</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">数据定义与赋值</font></span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px"><font color="#000080">函数和过程</font></span></strong></td msimagelist>
</tr>
</table msimagelist>
<hr>
<p><strong><span style="line-height: 24px">一、VB与Basic</span></strong></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%" msimagelist>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">VB之所以叫做“Visual
Basic”就是因为它使用了Basic语言作为代码,所以它们之间有着千丝万缕的关系,如果学过Basic的话,看到VB的程序结构会感到很亲切。但VB作为新生物,也超越了Basic的限制,有了许多自己的特点:</span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">VB建立了一种新的变量类型――货币型变量,通过使用仅带有二位小数的货币变量,就能避免因使用实型变量而带来的数值积累误差问题。</span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">VB在调用函数(Function)时,必须在函数名后跟一对括号。</span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">VB对白兰地使用范围重新做了规范,在Basic里把隐含变量都当作全局变量,而在VB里对隐含变量都当作局部变量。</span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">VB里的说明语句(Declare),仅支持动态链结库(DLL)的子程序和无变量函数。</span></strong></td msimagelist>
</tr>
<tr msimagelist>
<td valign="baseline" width="42" msimagelist><img src="bullet4.gif" width="13" height="12" hspace="14"></td>
<td valign="top" width="100%"><strong><span style="line-height: 24px">使用数组,必须事先用Dim或Redim进行定义。</span></strong></td msimagelist>
</tr>
</table msimagelist>
<hr>
<p><strong><span style="line-height: 24px">二、注释语句 </span></strong><ol>
<p ALIGN="JUSTIFY"><strong><span style="line-height: 24px">在使用注释语句之前必须先了解注释的作用,注释不仅仅是对程序的解释,有时它对于程序的调试也非常有用,譬如说可以利用注释屏蔽一条语句以观察变化,发现问题和错误。以后注释语句将是我们在编程里最经常用到的语句之一。</span></strong></p>
<p ALIGN="JUSTIFY"><strong><span style="line-height: 24px">在VB里,注释语句有两种,一种是用“Rem”关键字,这跟DOS里的批处理文件的用法一样,还有一种是利用单引号“’”,例如:</span></strong></p>
<p ALIGN="JUSTIFY"><strong><span style="line-height: 24px"><font color="#008000">‘Dim a
As String </font>与</span></strong></p>
<p ALIGN="JUSTIFY"><strong><span style="line-height: 24px"><font color="#008000">Rem Dim a
As String </font>的作用是一致的。</span></strong></p>
</ol>
<hr>
<p><strong><span style="line-height: 24px">三、长语句的分行</span></strong><ol>
<p ALIGN="JUSTIFY"><strong><span style="line-height: 24px">在比较早的版本中,因为没有象C等语言用“;”隔开语句与语句,VB的语句是必须写在一行里的,不过后来版本的VB里如许用分行符“_”把一个长语句分成若干行来存放。</span></strong></p>
</ol>
</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 + -