关于开关表达式的Reportviewer VB.NET [英] Reportviewer VB.NET about Switch Expression

查看:125
本文介绍了关于开关表达式的Reportviewer VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,谁都可以在rdlc表中更正我的代码

Hello everyone can anyone correct my codes in rdlc tables

我有1个表,并且在该表上有一个Field!ans1,它正在计算列的平均值(IMAGE中的RED CIRCLE),然后我希望将该平均值过滤为if语句,以识别该平均值是否为同意" ,不同意或完全不同意(图像中出现黑色圆圈)

i have 1 tables and on that table there was a Field!ans1 that was computing for the average of the column(RED CIRCLE in IMAGE) then i want that average to filter to an if statement to identify if that average is Agree , disagree or Stronglyagree(BLACK CIRCLE IN THE IMAGE)

这是我的RDLC表的图片 黑色圆圈是If语句,它将标识红色圆圈中的以下平均值是否为同意",不同意"或非常同意" 但我有一个问题,因为该语句即使价值为3,也总是存有不同意.

Here's the Picture of my RDLC Table the Black Circle is the If Statement that will identify if the Average Below in the Red Circle if is Agree,Disagree,or Strongly Agree but i am having a problem because the statement always stock on Disagree even its value is 3

// Here is my Code in the Black Circle in the IMAGE
=Switch(Fields!ans1.Value < 1, "Strongly Disagree ",
Fields!ans1.Value > 2, " Disagree",
Fields!ans1.Value > 3, "Agree",
Fields!ans1.Value > 4, "Strongly Agree"
)

//Here is the Code in the RedCircle 
=Avg(CDbl(Fields!ans1.Value))

推荐答案

请记住,任何类型的switch语句都是自顶向下进行评估的. 3.00是否大于2?是的,所以结果是不同意"(为什么您没有注意到并删除该恶意空间,我不知道).如果要使用大于"运算符进行比较,则需要首先比较最大值:

Remember that a switch statement of any kind is evaluated top-down. Is 3.00 greater than 2? Yes it is, so the result is " Disagree" (why you haven't noticed and removed that rogue space, I don't know). If you are going to compare using the 'greater than' operator then you need to compare the largest value first this:

=Switch(Fields!ans1.Value < 1, "Strongly Disagree",
Fields!ans1.Value > 4, "Strongly Agree",
Fields!ans1.Value > 3, "Agree",
Fields!ans1.Value > 2, "Disagree"
)

应该工作.那只是您在数学课上应该学习的基本逻辑.请注意,我也删除了该恶意空间.

should work. That's just basic logic that you should have learned in maths class. Note that I have removed that rogue space too.

顺便说一句,仍然会忽略1.0-2.0范围内的任何值.

By the way, that is still going to ignore any values in the range 1.0 - 2.0.

这篇关于关于开关表达式的Reportviewer VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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