网页有ListBox控件ID为ListBoxRight,然后一个输入框,tb_calculation,以前ListBoxRight加入一些项后,可以在输入框输入相关公式,比如ListBoxRight加入B后,可以输入 [kpi].[b],点击验证按钮通过;
如果加入B,C后,可以输入 [kpi].[b]+[kpi].[c],点击验证按钮通过。
现在希望加入B后输入sum([kpi].[all])点击验证按钮时输入框会变成 [kpi].[b]
如果加入B,C后输入sum([kpi].[all]) 点击验证按钮时输入框会变成[kpi].[b]+[kpi].[c]
现在希望加入B后输入average([kpi].[all])点击验证按钮时输入框会变成 [kpi].[b]  或者[kpi].[b]/1也行
如果加入B,C后输入average([kpi].[all]) 点击验证按钮时输入框会变成([kpi].[b]+[kpi].[c])/2
我的代码怎么不能正常显示啊?现在问题是输入sum([kpi].[all])后变成 sum([KPI].[all])[KPI].[A]
如果加入B 输入average([KPI].[all])后却显示 (average([KPI].[all])[KPI].[B])/1
再换成加入C则变成 (average([KPI].[all]))/0
帮忙看看:   string strAllKpi = this.tb_calculation.Text;
            if (this.tb_calculation.Text.IndexOf("[all]", System.StringComparison.OrdinalIgnoreCase) > 0)
            {
                foreach (ListItem li in this.ListBoxRight.Items)
                {
                  strAllKpi += "[KPI].[" + li.Text + "] +";    
                }
                if (strAllKpi.EndsWith("+")) { strAllKpi = strAllKpi.Substring(0, strAllKpi.Length - 2); } 
                if (this.tb_calculation.Text.IndexOf("average", System.StringComparison.OrdinalIgnoreCase) >= 0)
                { strAllKpi = "(" + strAllKpi + ")/" + ListBoxRight.Items.Count; }
                this.tb_calculation.Text = strAllKpi;
            }