关于VB的数组问题,我想让两个控件共享数组。
PrivateSubCommand1_Click()DimR!,k!Dima%(1To6)a(1)=Val(Text1)a(2)=Val(Text2)a(3)=Val(T...
Private Sub Command1_Click()
Dim R!, k!
Dim a%(1 To 6)
a(1) = Val(Text1)
a(2) = Val(Text2)
a(3) = Val(Text3)
a(4) = Val(Text4)
a(5) = Val(Text5)
a(6) = Val(Text6)
k = Combo1.Text
For i = 1 To 6
R = R + a(i) * k
Next i
Rx = R / 6 ‘计算平均值
Text7.Text = Rx
Command2.Enabled = True
End Sub
------------------------------------------
Private Sub Command5_Click()
Dim Ur%
For i = 1 To 6
ua = ua + (a(i) - Rx) ^ 2 command1中的a(1 to 6) 想用于此处
Next i
UUa = Sqr(ua / 5)
Text9.Text = UUa
'当我按command5的时候,系统显示错误:错误的参数或无效的属性赋值 展开
Dim R!, k!
Dim a%(1 To 6)
a(1) = Val(Text1)
a(2) = Val(Text2)
a(3) = Val(Text3)
a(4) = Val(Text4)
a(5) = Val(Text5)
a(6) = Val(Text6)
k = Combo1.Text
For i = 1 To 6
R = R + a(i) * k
Next i
Rx = R / 6 ‘计算平均值
Text7.Text = Rx
Command2.Enabled = True
End Sub
------------------------------------------
Private Sub Command5_Click()
Dim Ur%
For i = 1 To 6
ua = ua + (a(i) - Rx) ^ 2 command1中的a(1 to 6) 想用于此处
Next i
UUa = Sqr(ua / 5)
Text9.Text = UUa
'当我按command5的时候,系统显示错误:错误的参数或无效的属性赋值 展开
展开全部
你需要掌握的知识:变量的作用域
解决你的问题:
把
Private Sub Command1_Click()
Dim R!, k!
Dim a%(1 To 6)
a(1) = Val(Text1)
.........
Text7.Text = Rx
Command2.Enabled = True
End Sub
中的 Dim a%(1 To 6)
搬到代码窗体的最上面一行,这样
Dim a%(1 To 6)
......
......
Private Sub Command1_Click()
Dim R!, k!
a(1) = Val(Text1)
.........
Text7.Text = Rx
Command2.Enabled = True
End Sub
,,,,,,
解决你的问题:
把
Private Sub Command1_Click()
Dim R!, k!
Dim a%(1 To 6)
a(1) = Val(Text1)
.........
Text7.Text = Rx
Command2.Enabled = True
End Sub
中的 Dim a%(1 To 6)
搬到代码窗体的最上面一行,这样
Dim a%(1 To 6)
......
......
Private Sub Command1_Click()
Dim R!, k!
a(1) = Val(Text1)
.........
Text7.Text = Rx
Command2.Enabled = True
End Sub
,,,,,,
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询