首页 \ 问答 \ 如何计算阵列的平均值?(How do I calculate the average of an array?)

如何计算阵列的平均值?(How do I calculate the average of an array?)

 Public Class Form1
Dim x As Integer
Dim y(9) As Double
Dim average As Double
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    For x = 0 To 9
        y(x) = x
    Next
    average = y(9) / 10
    Label1.Text = average
End Sub
End Class

我在计算0到9数组的平均值时遇到了问题,我意识到我的代码只会计算9除以10,如何继续计算10个数的平均值?


 Public Class Form1
Dim x As Integer
Dim y(9) As Double
Dim average As Double
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    For x = 0 To 9
        y(x) = x
    Next
    average = y(9) / 10
    Label1.Text = average
End Sub
End Class

I'm having trouble trying to calculate the average of 0 to 9 array, I realize that my code is only going to calculate 9 divided by 10, How do I proceed with calculating the average of the 10 numbers?


原文:https://stackoverflow.com/questions/37272389
更新时间:2022-10-08 16:10

最满意答案

首先,我想提请您注意,使用业务或流程变量来存储已存储在外部数据库中的数据将导致重复。 建议的解决方案是使用REST API扩展(例如REST API SQL数据源 )来查询外部数据库中的数据,并在表单中使用此REST API扩展。

现在,如果您可以复制数据,可以参考我创建的示例 ,演示如何使用PostgreSQL连接器输出设置流程和业务数据,然后在表格窗口小部件中显示变量。

我强烈建议使用业务变量,如果可能,请考虑将数据从外部数据库迁移到业务数据数据库。


First of all I want to draw your attention that using business or process variables to store data already stored in an external database will lead to duplication. Recommended solution would be to use a REST API extension (such as REST API SQL data source) to query the data from the external database and use this REST API extension in the forms.

Now if you are ok with duplication of data you can refer to an example I create that demonstrate how to set process and business data with PostgreSQL connector output and then display the variables in form table widgets.

I highly recommend to use business variable and if possible consider migrating the data from the external database to the business data database.

相关问答

更多
  • 这应该告诉你你到底需要什么: http : //msdn.microsoft.com/en-us/library/aa259186(v = sql.80).aspx this should tell you exactly what you need: http://msdn.microsoft.com/en-us/library/aa259186(v=sql.80).aspx
  • 如果我快速观察实例变量,它也具有“测试”的值。 当我播放到Page_Load时,实例变量的值为null。 你没有看到实例变量,你会看到局部变量。 实例变量从不设置,因为本地作用域变量在作用域生存期内隐藏实例变量。 从规格: 3.7.1名称隐藏 实体的范围通常包含比实体的声明空间更多的程序文本。 具体而言,实体的范围可能包括声明,其中引入了包含同名实体的新声明空间。 这些声明导致原始实体隐藏起来 。 相反,一个实体在没有隐藏时被认为是可见的。 名称隐藏发生在范围通过嵌套重叠并且范围通过继承重叠时发生。 以下部 ...
  • 因为您的查询(Where(...))没有被执行。 我假设过滤器是从循环中获得的? Linq查询在使用之前不会执行。 因此,如果您通过一堆过滤器循环然后开始执行它们,则查询中的过滤器值将是错误的。 类似的问题: 访问Modified Closure还: http : //devnet.jetbrains.net/thread/273042 需要看到更多代码才能100%肯定。 Because your query(Where(...)) is not being executed. I assume filte ...
  • 自从IDEA 6以来,GUI Designer没有多大变化。我将从内置的帮助系统或其在线副本开始 。 GUI Designer didn't change much since IDEA 6. I'd start with the built-in help system or its online copy.
  • 对于这个问题抱歉,情况如下: UI设计者插件目前尚未开发,并且与AppCode 2016.1不兼容。 最近我们发现有关UI设计人员的一些帮助资源已经过时并使我们的用户感到困惑,因为现在所有这些资源都是最新的。 该插件本身因兼容性原因被保留,并且不能与AppCode 2016.1一起使用 Sorry for this issue, situation is the following: UI designer plugin is currently not in active development and ...
  • 当你有一个检索操作时,我发现动词被忽略了。 您需要传递的只是具有您要搜索的字段值的BO。 I found out that the verb is ignored, when you have a retrieve operation. All you have to pass is the BO with the field values you want to search for.
  • 在你的第一个例子中: 你的外部i不是“全局变量”,它是一个实例属性(有时称为实例变量)。 第一个示例中的代码有效,因为当您使用非限定符号时,会选择范围最窄的符号。 (声明“最接近”使用它的代码。)因此, Something构造函数中的不合格i是i参数,您必须使用this来访问您的实例字段。 JLS§6.5.6.1中的 Gory详细信息: 简单表达式名称 。 如果没有范围较窄的标识符,则可以省略this. 访问字段(和方法),但不存在具有较窄范围的冲突标识符时。 例: class Example { ...
  • 首先,我想提请您注意,使用业务或流程变量来存储已存储在外部数据库中的数据将导致重复。 建议的解决方案是使用REST API扩展(例如REST API SQL数据源 )来查询外部数据库中的数据,并在表单中使用此REST API扩展。 现在,如果您可以复制数据,可以参考我创建的示例 ,演示如何使用PostgreSQL连接器输出设置流程和业务数据,然后在表格窗口小部件中显示变量。 我强烈建议使用业务变量,如果可能,请考虑将数据从外部数据库迁移到业务数据数据库。 First of all I want to dra ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。