VB中全局变量的问题
我创建了一个窗体和一个按钮,然后想通过点击按钮后为全局变量赋值,编制的代码如下:通用部分:PublicSubtec()Publica()AsDoublePublicnAs...
我创建了一个窗体和一个按钮,然后想通过点击按钮后为全局变量赋值,编制的代码如下:
通用部分:
Public Sub tec()
Public a() As Double
Public n As Double
a = 0
n = 0
End Sub
按钮部分:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim b As Double
i = 1
b = 0
For i = 1 To 3 Step 1
b = b + i
a(i) = b
Next i
n = i
Label1.Caption = a(3)
End Sub
试运行后提示子过程或函数未定义,光标指向在a(i)处,求教该如何修改? 展开
通用部分:
Public Sub tec()
Public a() As Double
Public n As Double
a = 0
n = 0
End Sub
按钮部分:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim b As Double
i = 1
b = 0
For i = 1 To 3 Step 1
b = b + i
a(i) = b
Next i
n = i
Label1.Caption = a(3)
End Sub
试运行后提示子过程或函数未定义,光标指向在a(i)处,求教该如何修改? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询