If you are a business application programmer, you need to take null values seriously, especially when accessing and referencing data from a database. In my experience as a programmer, this is one of most causes of runtime error in programs written by newbie (even experienced) programmers.
This function help you in handling null values from a database. It will checks a value for null and returns a non-null value or a default value.
'Language: Visual Basic 6 (VB6)
'Parameter: varValue = the value that needs to be handle
' varNullValue = the optional value to return in
' case the varValue is Null
'Usage: MsgBox IfNull(rst!name, "kabalweg")
Public Function IfNull(varValue As Variant, Optional varNullValue As Variant = "") As Variant
If IsNull(varValue) Or varValue = "" Then
IfNull = varNullValue
Else
IfNull = varValue
End If
End Function
0 comments:
Post a Comment