列表框钙蛋白 [英] ListBox calculatins

查看:85
本文介绍了列表框钙蛋白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heey
我对拼贴画有一个粗略的称呼,即视觉编程",我们使用视觉c#"
我已经做到了,但是仍然有一个问题,即如何计算我在列表框中添加的项目的平均值

{就像我们有一个文本框,每次我想输入一个学生的格数",当我单击平均值"按钮时,它必须计算平均值并将其显示在标签中}:confused :: confused:

我的问题是我不知道该怎么做:((

heey
I have an assinment for collage for a coarse called " visual programming" we use the " visual c# "
i have done it but still have one single problem which is how to calculate the average of the items i added in the list box

{it is like we have a textbox and each time i suppose to type a grage of a student" and when i click in the average button it has to calculate the average and display it in a lable}:confused: :confused:

my problem is i couldn''t figure out how to do the average thing :((

推荐答案

我知道如何计算平均值

i know how to caculate the average

private void Average_Click(object sender, EventArgs e)<br />
        {<br />
            <br />
            double sum = 0;<br />
            //Listboxth.Items = int.Parse();<br />
            for (int i = 0; i < Listboxth.Items.Count; i++)<br />
                sum += Listboxth.Items.IndexOf(i);<br />
            average = sum / Listboxth.Items.Count;<br />
<br />
        }



这就是我的方法...但是仍然不知道它是否有效..:s

而且我不知道如何在标签中显示平均值:



this is how i did it ... but still don''t know if it worked .. :s

and i couldn''t figure out how to display the average in the lable:

private void label2_Click(object sender, EventArgs e)<br />
        {<br />
            string avrg;<br />
            avrg = average;<br />
            label2.Text = avrg;<br />
        }



^我知道转换有问题,也许X |

顺便说一句,我是编程和可视化编程的新手,刚好两个月前才开始..



^ i know there is something wrong with the conversion maybe X|

btw i am new in programming and visual programming just started two monthes ago ..


将这些值相加即可得到总和,然后除以值的数量即可得到平均值.确实是小学数学.
Add the values together to get the sum and divide by the number of values to get the average. Elementary mathematics really.


将所有值相加,然后将该数字除以所添加值的总数.例如,给定以下三个值:
Add up all the values, then divide that number by the total number of values added. For example, given these 3 values:
1
2
3


您将它们加起来:1 + 2 + 3 = 6
然后将它们除以项目总数:6/3 =2.
因此平均值为2.


You add them up: 1 + 2 + 3 = 6
Then you divide them by the total number of items: 6 / 3 = 2.
So the average is 2.


这篇关于列表框钙蛋白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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