Options
Option Explicit
You must explicitly define each variable that you use.
Option Private Module
You can force all procedures in a module to be private - even those declared with the Public keyword.
You can omit the Private keyword from your Sub declarations.
Option Base [01]
The lower bound of an array, created using the Array function, is determined by Option Base statement at the top of the module. The default lower bound is 0
Declaring Variables
Dim
变量
As
String
变量
=
"
initialization
"
Const
常量
As
String
=
"
initialization
"
Dim
定长字符串
As
String
*
10
定长字符串
=
"
超过ten个无效(中文英文都算1个,看来编码用的unicode)
"
Executing Sub from another Procedure
Option
Explicit
Sub
executingWay()
add
"
flame
"
,
1
,
2
Call
add(
"
call
"
,
1
,
2
)
Dim
subName
As
String
: subName
=
"
add
"
Run subName,
"
run
"
,
1
,
2
End Sub
Sub
add(exeBy
As
String
, x
As
Integer
, y
As
Integer
)
MsgBox
exeBy
&
"
:
"
&
(x
+
y)
End Sub
Executing Function from another Procedure
Option
Explicit
Function
executingWay()
Debug.Print add(
"
flame
"
,
1
,
2
)
Dim
funcName
As
String
: funcName
=
"
add
"
Debug.Print Run(funcName,
"
run
"
,
1
,
2
)
End Function
Function
add(exeBy
As
String
, x
As
Integer
, y
As
Integer
)
As
String
add
=
exeBy
&
"
:
"
&
(x
+
y)
End Function
posted on 2008-03-20 11:16
Jcat 阅读(221)
评论(0) 编辑 收藏 所属分类:
VBA