开发者

divide by 0 problem vb.net

How Can I make sure PCTofSales, is not 0.

  'gets the projected sales by dividing the currentsales by the percent of sales
    Dim projectedye As New DataColumn
    projectedye 开发者_运维百科= New DataColumn("ProjSales", GetType(Double))
    projectedye.Expression = "CurrentSales / (PCTofSales)"


Assuming you're using .NET 3.5:

pctofsales.Expression = "IIF([YEsales] = 0, 0, [ASOFSales] / [YEsales])"

See here:MSDN's article for information about functions you can use inside the expression.


Can you not use an IF THEN to call the function when:

"[ASOFSales] / [YEsales]"

equals zero or is inappropriate to divide?


Run an update on your dataset to change all 0's to NULLs OR change your datasource to return NULLs instead of 0s in the PCTofSales/other column(s).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜