运行时错误340-控制阵列元素“0”。不存在 [英] Runtime Error 340 - Control Array Element "0" does not exist

查看:288
本文介绍了运行时错误340-控制阵列元素“0”。不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在接受 运行时错误340-控制阵列元素"0"在执行样本统计的VB6代码时不存在。

I am getting  Runtime Error 340- Control Array Element "0) does not exist, while executing the VB6 code for Sample Statistics.

我创建了5个标签"随机数据样本","平均" ;,"标准偏差","DataMin",和"DataMax"同时将Index属性分别设置为1,0,1,2,3,并且还创建了5个列表框,分别为上面的
标签的List1,List2,List3,List4和List5代码如下:

I have created 5 labels "Random Data Sample", "Average", "Standard Deviation", "DataMin" and "DataMax" with Index property as 1, 0, 1,2, 3 respectively and also created  5 list boxes i.e. List1, List2, List3, List4 and List5 respectively for the above labels with the code as under :

Function ArrayStats(DataArray() As Double) As Double()
Dim Res(4) As Double
     Sum = 0
     SumSquares = 0
     DCount = 0
     DataMin = 999999
     DataMax = 999999
     For i = LBound(DataArray) To UBound(DataArray)
          Sum = Sum + DataArray(i)
          SumSquares = SumSquares + DataArray(i) ^ 2
          If DataArray(i) > DataMax Then DataMax = DataArray(i)
          If DataArray(i) < DataMin Then DataMin = DataArray(i)
          DCount = DCount + 1
    Next
    Avg = Sum / DCount
    StdDev = Sqr(SumSquares / DCount - Avg ^ 2)
    Res(1) = Avg
    Res(2) = StdDev
    Res(3) = DataMin
    Res(4) = DataMax
    ArrayStats = Res()
    End Function
    
Private Sub Command1_Click()
Dim SData(100) As Double
Dim Stats() As Double

     List1.Clear
     For i = 1 To 100
           SData(i) = Rnd() * 10000
           List1.AddItem SData(i)
      Next
      Stats() = ArrayStats(SData())
      For i = 1 To 4
              lblSTATS(i - 1).Caption = Stats(i)
      Next
End Sub




Pl。帮助解决问题。


Pl. help in resolving the problem.

推荐答案

你好hksahoo,

Hi hksahoo ,

谢谢你发帖。

这个队列是关于vb.net的。我担心你关于VB6代码的话题不适合这里。我将把这个帖子移到主题论坛上。您可以通过以下链接找到正确的论坛:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b

This queue is about vb.net. I’m afraid that your topic about VB6 code is unsuitable here. I will move this thread to off topic forum. You can find the correct forum with the help of this link: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b.

很抱歉给您带来不便,祝您有个愉快的一天。

Sorry for any inconvenience and have a nice day.


这篇关于运行时错误340-控制阵列元素“0”。不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆