Difference between revisions of "ZH/Documentation/BASIC Guide/Constants"

From Apache OpenOffice Wiki
Jump to: navigation, search
(New page: {{DISPLAYTITLE:常量}} {{ZH/Documentation/BASICGuideTOC/v2 |ShowPrevNext=block |ShowPrevPage=block |PrevPage=Documentation/BASIC Guide/Scope of Variables |NextPage=Documentation/BASIC Gui...)
 
Line 24: Line 24:
 
== 常量的作用域 ==
 
== 常量的作用域 ==
  
常量具有与变量相同的作用域(请参见[[Documentation/BASIC Guide/Scope of Variables|变量的作用域和生命周期]]),但语法略有不同。模块标头中的 <tt>Const</tt> 定义可以在该模块的代码中使用。要使该定义可用于其他模块,请添加 <tt>Public</tt> 关键字。
+
常量具有与变量相同的作用域(请参见[[ZH/Documentation/BASIC Guide/Scope of Variables|变量的作用域和生命周期]]),但语法略有不同。模块标头中的 <tt>Const</tt> 定义可以在该模块的代码中使用。要使该定义可用于其他模块,请添加 <tt>Public</tt> 关键字。
  
 
<source lang="oobas">
 
<source lang="oobas">

Revision as of 16:33, 13 November 2008

doc OOo
Book.png

常量是程序可以使用但不能更改的值。

定义常量

在 Apache OpenOffice Basic 中,使用关键字 Const 来声明常量。

Const A = 10

还可以在声明中指定常量类型:

Const B As Double = 10

常量的作用域

常量具有与变量相同的作用域(请参见变量的作用域和生命周期),但语法略有不同。模块标头中的 Const 定义可以在该模块的代码中使用。要使该定义可用于其他模块,请添加 Public 关键字。

Public Const one As Integer = 1
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools