自定义函数实现三个字段求和及合并

时间:2008-10-07 12:05:24  来源:第二电脑网上收集  作者:

  第二电脑网导读:= 0 ThenValHecheng = aEnd If'如果B不为0且C为0If b > 0 And c = 0 ThenValHecheng = a + bEnd If'如果全部不为0If b > 0 And c > 0 ThenValHecheng = a + b + cEnd IfEnd Function'合并字段函数Function strHecheng(a As Long, b As Long, c As Long) As StringIf b = 0 And c = 0 Th...
  正文:

第一步:新建一模块,命名为:module1,将下面的函数复制到模块中:

'求和字段函数
Function ValHecheng(a As Long, b As Long, c As Long) As Long
'首先我们知道a肯定是不会为0的
'如果B为0并且C为0
If b = 0 And c = 0 Then
ValHecheng = a
End If
'如果B不为0且C为0
If b > 0 And c = 0 Then
ValHecheng = a + b
End If
'如果全部不为0
If b > 0 And c > 0 Then
ValHecheng = a + b + c
End If

End Function

'合并字段函数
Function strHecheng(a As Long, b As Long, c As Long) As String
If b = 0 And c = 0 Then
strHecheng = a
End If
If b > 0 And c = 0 Then
strHecheng = a & "+" & b
End If
If b > 0 And c > 0 Then
strHecheng = a & "+" & b & "+" & c
End If
End Function

第二步:新建一查询,应用上面的函数,详见示例。

示   例:

点击浏览该文件


"自定义函数实现三个字段求和及合并"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/ASP/2008-10-07/2981.html


关键字:

关于《自定义函数实现三个字段求和及合并》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td