📄 ac2k1603.htm
字号:
<html>
<head>
<title>洪恩在线 - Access 2000</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../../../pub/css/home.css">
<link rel="stylesheet" href="/pc/pc.css">
<meta name="keywords" content="电脑,教育,教程,办公软件,microsoft,Office,office,Access,Access 2000,数据库">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!--顶部开始-->
<script language="Javascript" src="/pub/js/head.js"></script>
<!--顶部结束-->
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
<tr>
<td height=20 class="p1" bgcolor="#E8E8E8" align="left"><img src="/pc/img/blank.gif" width="12" height="8"><font color="#000000"><font color="#FF9966">当前位置</font>:<a href="http://www.book52.com/">LR电脑书籍网 </a> → <a href="http://www.book52.com/soft/">电脑书下载 </a> → <a href="http://www.book52.com/soft/sort06/list6_1.html">数据库类 </a> → <a href="http://www.book52.com/soft/sort06/sort049/list49_1.html">Access书籍 </a> <font color="#330099">→</font> Access 2000</font></td>
</tr>
</table>
<table width="760" border=0 cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="15"></td>
</tr>
</table>
<table width="760" cellspacing="0" border=0 cellpadding="0" align="center">
<tr>
<td width="145" valign="top" bgcolor="#E8E8E8" align="left" style="color:blue" height="183">
<img src="/pc/img/blank.gif" width="1" height="10" align=center><br>
<table width="145" border="0" cellspacing="0" cellpadding="0" bordercolor="#F8AC0E" align="center" height="20">
<tr bgcolor="000099" valign="middle">
<td width="109" align="center" class="p2"><font color="#FFFFFF"><b>Access
2000</b></font><font color="#FF3333" ><b></b></font></td>
<td height="20" bgcolor="#E8E8E8" width="13"><img src="/pc/img/title_00.gif" width="13" height="20"></td>
<td height="20" bgcolor="#E8E8E8" width="23"> </td>
</tr>
</table>
<p style="line-height:17pt" align="left"><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12">
<a href="ac2k0101.htm">初识Access 2000<br>
</a></font><font color="#0000CC"> </font></span><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12">
<a href="ac2k0201.htm">窗口接口使用简介<br>
</a></font></span><font color="#0000CC"><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0301.htm">用向导建立数据库</a></span></font><font color="#0000CC"><span class="p1"><a href="ac2k0301.htm">
<br>
</a><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0401.htm">数据库的结构</a> <span class="p1"><a href="ac2k0403.htm">
</a></span> <br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0501.htm">用表向导建立表</a></span></font> <font color="#0000CC"><span class="p1"><a href="ac2k0501.htm">
<br>
</a><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0601.htm">在表中输入数据</a> <a href="ac2k0601.htm"><br>
</a><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0701.htm">数据的类型和属性</a><span class="p1"> </span><br>
</span></font><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0801.htm">定义表之间的关系</a></span><span class="p1"><br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k0901.htm">建立简单的查询</a></span><span class="p1"> <br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1001.htm">为查询制定规则</a><br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1101.htm">如何建立数据窗体<br>
</a><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1201.htm">生成数据打印报表</a></span><span class="p1"><br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm">为WEB页提供数据</a></span><span class="p1"> <br>
<font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><span class="p1"><a href="ac2k1401.htm">用图表显示数据</a></span>
<br>
<span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><span class="p1"><a href="ac2k1501.htm">宏的使用</a></span>
<br>
<span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><span class="p1">模块与“VBA”语言</span></p>
<p style="line-height:17pt" align="left"><span class="p1"> <a href="ac2k1601.htm">什么是VBA和模块</a><br>
<a href="ac2k1602.htm">VBA开发环境</a><br>
变量和常量<br>
<a href="ac2k1604.htm">函数和子程序</a> <br>
</span><br>
<span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><a href="ac2k1701.htm"><span class="p1">SQL语言妙用</span><br>
</a><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><a href="ac2k1801.htm"><span class="p1">外部数据的使用</span><br>
</a><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><a href="ac2k1901.htm"><span class="p1">数据的优化和安全</span><br>
</a><span class="p1"><font color="#0000CC"><img src="img/small.gif" width="12" height="12"></font>
<a href="ac2k1301.htm"></a></span><span class="p1"></span><a href="ac2k2001.htm"><span class="p1">容易忽略的工作</span></a></p>
<p style="line-height:17pt" align="left"> </p>
<p align="center" class=p1><a href=/pc/bin/msg.pl?file_id=k_ac2k_16 target="_blank"><img src="/pc/img/message.gif" width="64" height="54" alt="请您留言" border="0"><br>
谈谈您的看法</a> <br>
<script language="javascript">
speak_num="za"
</script>
<script language="javascript" src=/pc/var/pc_k_ac2k_16.js>
</script>
<script language="javascript">
var num=0
if (!isNaN(speak_num)){
num=speak_num;
}
else{
num=0
}
document.writeln ("已有")
document.writeln (num)
document.writeln ("条发言")
</script>
</p>
<p> </p>
<p> </p>
<p> </p>
</td>
<td width=1 bgcolor=#0586D7 height="183"><img src="/pc/img/blank.gif" width="1" height="1">
</td>
<td valign="top" bgcolor="#FFFFFF" background="/pc/img/line.gif" width="614" height="183">
<table width="95%" border="0" align="center">
<tr background="/pc/img/line.gif">
<td colspan="2" class="p3" height="50">
<div align="center"><font color="#003333"><b><font color="#ff3333">
变量和常量</font></b></font></div>
</td>
</tr>
<tr background="/pc/img/line.gif">
<td class="p2" style="line-height:17pt">
<p> 在做这个程序之前必须要申请变量,并对其中要用到的常量进行定义。</p>
<p> 这儿的变量和我们在数学中所遇到的变量的概念基本上是一样的,它是一个数据,但随时可以改编它所对应的数值。 常量这个概念和变量是对应的,变量的值在程序运行过程当中允许变化,而常量的值却是不变的。</p>
<p align="center"><img src="img/ac2k1603.gif" width="300" height="182" alt="变量插图" border="1"></p>
<p align="center"><img src="img/ac2k1604.gif" width="320" height="163" alt="常量插图" border="1"></p>
<p> 在计算机中,变量和常量在使用之前都必须先定义,不然在程序当中就会被认为是非法的字符。 在VBA中,有几种定义变量和常量的方法,首先,我们可以用“Public
Const 常量名= 常量表达式”来定义一个常量,就像<br>
Public const PI = 3.1415926<br>
这个语句就定义了一个很常用的常量,以后当我们想使用圆周率的时候只要用“PI”代替就可以了。在这个语句中“Public”用来表示这个常量的作用范围是整个数据库的所有过程。如果我们这时用“Private”来代替它,则这个常量只能在现在的这个模块中使用了。“Const”语句用来表示要申明的是个常量而非变量。
</p>
<p align="center"><img src="img/ac2k1605.gif" width="320" height="209" alt="定义常量和变量插图" border="1"></p>
<p> 申请变量和申请常量差不多,通常我们用“Dim 变量 As 变量类型”语句来申明一个变量,其中“Dim”和常量申请语句中的“Const”作用类似,它告诉Access,现在申请的是“变量”而不是常量。比如<br>
Dim number As Integer<br>
就是说现在我们申明了一个整数类型的变量“number”,以后在程序中“number”就表示一个变量,而不再是普通的字符组合了。变量在程序中可以被赋予新的值,“number
= 4”这个语句就是一个赋值语句。这样变量“number”就有了一个值“4”。如果后来又有一个相似的语句“number = 3223”,则变量“number”的值就会变成“3223”了。
让我们看一个例子: <br>
Public Const PI=3.1415926 <br>
DIM a,number As Integer <br>
number = 159 <br>
a = number *23/ PI+323 <br>
在四个语句中,第一条申明了一个常量“PI”,第二条申明了两个整数类型的变量“a”和“number”,第三条是一个赋值语句,通过它将变量“number”赋予值“159”,而第四条语句则是将变量“number”的值乘以“23”,然后除以常量“PI”,也就是除以“3.1415926”,然后将所得的值加上“323”,并把最终的值赋给变量“a”。
</p>
<p> </p>
</td>
</tr>
</table>
<p align="center"><a href="ac2k1602.htm" class="p1">上一页</a> <a href="ac2k1604.htm" class="p1">下一页</a><font size="2"> </font></p>
<p align="center"> </p>
<p align="center" class=p2><a href=/pc/bin/msg.pl?file_id=k_ac2k_16 target="_blank"><img src="/pc/img/message.gif" width="64" height="54" alt="请您留言" border="0"><br>
谈谈您的看法</a>
<script language="javascript">
speak_num="za"
</script>
<script language="javascript" src=/pc/var/pc_k_ac2k_16.js>
</script>
<script language="javascript">
var num=0
if (!isNaN(speak_num)){
num=speak_num;
}
else{
num=0
}
document.writeln ("已有")
document.writeln (num)
document.writeln ("条发言")
</script>
</p>
</td>
</tr>
</table>
<!--底部开始-->
<script language="Javascript" src="/pub/js/foot.js"></script>
<!--底部结束-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -