Foxtable(狐表)用户栏目专家坐堂 → 自动默认为0的函数如何写?


  共有3262人关注过本帖树形打印复制链接

主题:自动默认为0的函数如何写?

帅哥哟,离线,有人找我吗?
owenlyx
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:213 积分:2237 威望:0 精华:0 注册:2012/9/3 16:21:00
自动默认为0的函数如何写?  发帖心情 Post By:2015/11/11 20:50:00 [只看该作者]

代码如下:
Dim dr As DataRow
Dim dd As DataRow 
Dim dc As DataRow  
dr = DataTables("进货明细").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dd= DataTables("销售表").find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dc= DataTables("退货表").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 退货款号 = '" & e.Form.Controls("combobox2").text & "'")
‘If dr IsNot Nothing And dd IsNot Nothing And dc IsNot Nothing Then  
e.Form.Controls("label11").text = dr("件数") - dd("件数") -dc("件数")  

用什么函数可以设置 ’销售表‘里找不到此行自动默认为0 ,同理‘退货表’ 也是一样,请问代码如何写? 

 回到顶部
帅哥哟,离线,有人找我吗?
qtcks
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:485 积分:3926 威望:0 精华:6 注册:2009/3/29 13:25:00
  发帖心情 Post By:2015/11/12 2:55:00 [只看该作者]

Dim dr As DataRow
Dim dd As DataRow 
Dim dc As DataRow  
dr = DataTables("进货明细").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dd= DataTables("销售表").find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dc= DataTables("退货表").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 退货款号 = '" & e.Form.Controls("combobox2").text & "'")
‘If dr IsNot Nothing And dd IsNot Nothing And dc IsNot Nothing Then  
e.Form.Controls("label11").text = IIF(dr = Nothing ,0,dr("件数")) - IIF(dd = Nothing,0,dd("件数")) -IIF(dc = Nothing,0,dc("件数")  )

 回到顶部
帅哥哟,离线,有人找我吗?
Hyphen
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2015/11/12 9:00:00 [只看该作者]

e.Form.Controls("label11").text = IIF(dr = Nothing ,0,IIF(dr.IsNull("件数"),0,dr("件数"))) - IIF(dd = Nothing,0,IIF(dd.IsNull("件数"),0,dd("件数"))) -IIF(dc = Nothing,0,IIF(dc.IsNull("件数"),0,dc("件数"))  )

 回到顶部
帅哥哟,离线,有人找我吗?
owenlyx
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:213 积分:2237 威望:0 精华:0 注册:2012/9/3 16:21:00
  发帖心情 Post By:2015/11/12 11:57:00 [只看该作者]

谢谢

 回到顶部
帅哥哟,离线,有人找我吗?
owenlyx
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:213 积分:2237 威望:0 精华:0 注册:2012/9/3 16:21:00
  发帖心情 Post By:2015/11/12 22:23:00 [只看该作者]

但是一直还是报错。 
我用的代码是这个:
Dim dr As DataRow
Dim dd As DataRow 
Dim dc As DataRow  
dr = DataTables("进货明细").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dd= DataTables("销售表").find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 基本款号 = '" & e.Form.Controls("combobox2").text & "'")
dc= DataTables("退货表").Find("条码号 = '"& e.Form.Controls("combobox1").text & "'and 退货款号 = '" & e.Form.Controls("combobox2").text & "'")
'If dr IsNot Nothing And dd IsNot Nothing And dc IsNot Nothing Then  
e.Form.Controls("label11").text = IIF(dr Is Nothing ,0,dr("件数")) - IIF(dd Is Nothing,0,dd("件数")) -IIF(dc Is Nothing,0,dc("件数"))

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20151112221812.png
图片点击可在新窗口打开查看


[此贴子已经被作者于2015/11/12 22:23:07编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/12 22:28:00 [只看该作者]

Dim sum As Double = 0
If dr IsNot Nothing
    sum = dr("件数")
End If
If dd IsNot Nothing
    sum = sum - dd("件数")
End If
If dd IsNot Nothing
    sum = sum - dc("件数")
End If

e.Form.Controls("label11").text = sum


 回到顶部