Let's take a look at the differences between the two functions.
1. Private Function geteachqty () Function Geteachqty ( Byval OBJ As Object ) As Integer
If Isdbnull (OBJ) = False Then
Return Convert. toint32 (OBJ)
Else
Return 0
End If
End Function
2. Private Function geteachqty () function geteachqty ( byval OBJ as Object ) as integer
return IIF ( isdbnull (OBJ ), 0 , convert. toint32 (OBJ)
End Function
Same, different, same, different ........
I think it is different. Based on my test results, I guessCode2 closer to code 3
3. Private Function geteachqty () Function Geteachqty ( Byval OBJ As Object ) As Integer
Dim Resule As Integer = Convert. toint32 (OBJ)
If Isdbnull (OBJ) = False Then
Return Resule
Else
Return 0
End If
End Function
If I guess it is true, then the IF and IIF are essentially different and cannot be exchanged at all. You must be careful when using them.