折边加工:dim写在哪

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/11 03:22:16
vb里的类似这个Dim x!,N1!,N2!
写在什么地方
详细点吧

Option Explicit
Dim a As Integer

Private Sub Form_Load()
Dim a As Integer
Dim b As String
Dim c As Variant
End Sub
Function CalculateSquareRoot(NumberArg As Double) As Double
Dim k As Integer

If NumberArg < k Then
Exit Function
Else
CalculateSquareRoot = Sqr(NumberArg)
End If
End Function
这个例子告诉我们可以写在所有的地方,但是用法和作用是不一样的。

一般写在过程中而且要写在调用它之前(只能写在过程中,函数中,事件等过程当中,).属于局部变量.

如果没有Option Explicit ,不写也可以,其实写在哪里都可以了,只要不在Option Explicit 的上边就ok
不过这样不够标准哦~~,一般来讲,写在类或者函数的头部,如果在类的头部,那么该变量为Public,在函数内部的头部的话,为private