使用Visual Studio 2005的Excel标准偏差 [英] Using Excel Standard Deviation for Visual Studio 2005

查看:92
本文介绍了使用Visual Studio 2005的Excel标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我在网上搜索如何进行编码以计算标准偏差,并遇到了在Visual Studio中使用Excel来为数据集计算StDev的想法.

我按照如下方法应用编码,尝试使用Excel StDev进行数学运算.

Hello everyone : )

I was searching online on how to do coding to calculate standard deviation and came across the idea of using Excel in Visual Studio to calculate StDev for a dataset.

I apply the coding as followed to try using Excel StDev to do the math.

Private Function Compute(ByVal data As ArrayList) As Double

        Dim result As Double = 0.0
        Dim sum As Double = 0.0
        Dim i As Integer = 0
        Dim count As Integer = 0


        'CALCULATE AVERAGE
        If ComputationType.Equals("Average") Then

            For i = 0 To data.Count - 1
                If data(i) Is DBNull.Value Then 'IMPORTANT! SOME RECORD HAS NULL VALUE SO MUST ADD A ZERO
                    sum += 0
                Else
                    sum += data(i)
                End If

                count += 1
            Next i

            result = sum / data.Count

            'CALCULATE STANDARD DEVIATION
        ElseIf ComputationType.Equals("STDev") Then

            result = Application.WorksheetFunction.StDev(data(i))

           Return result

    End Function



但是,Visual Studio表示Application.WorksheetFunction不是System.Windows.Forms.Application的成员.

如果某些专业人士可以向我解释出了什么问题以及如何解决此问题,我将不胜感激.非常感谢:)



However, Visual Studio says that Application.WorksheetFunction is not a member of System.Windows.Forms.Application.

I will greatly appreciate if some pros can explain to me what went wrong and how to solve this problem? Thank you very much :)

推荐答案

您需要导入Microsoft.Office.Interop.Excel名称空间(并引用相应的程序集). 此处 [ ^ ],您可能会找到示例代码.

但是,对于这样一个相对简单的任务,我将不使用<code> Excel,毕竟VB.NET是一种功能齐全的编程语言:请检查函数定义(例如 ^ ])并自行编写代码.
You need to import Microsoft.Office.Interop.Excel namespace (and reference the corrensponding assembly).
Here[^] you may find sample code.

However, for such a relatively simple task I won''t use <code>Excel, after all VB.NET is a fully-featured programming language: check out the function definition (for instance here[^]) and code it yourself.


这篇关于使用Visual Studio 2005的Excel标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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