Hi,
I think that I have a simple one here. I have a parameter defined as an optional integer being passed into a subroutine. If I don't provide a value for the parameter, it comes out as a value of zero in the subroutine. How do I make it so that if no value is given, nothing or null is returned as opposed to zero. I'm using the following code:
A point in the right direction here would be greatly appreciated. Thanks.
- VB Rookie
I think that I have a simple one here. I have a parameter defined as an optional integer being passed into a subroutine. If I don't provide a value for the parameter, it comes out as a value of zero in the subroutine. How do I make it so that if no value is given, nothing or null is returned as opposed to zero. I'm using the following code:
Code:
Private Sub IReference_getReferences(ByVal refCategory As Integer, Optional refNumber As Integer, Optional ByVal orderBy As String)
Dim sql As String
sql = "select * " & _
"from site_reference " & _
"where ref_category = " & refCategory
If Len(refNumber) > 0 Then
sql = sql & " and ref_Nbr = " & refNumber
End If
If Len(orderBy) > 0 Then
sql = sql & " order by " & orderBy & ""
End If
Set rs = adoConnection.Execute(sql)
End Sub
A point in the right direction here would be greatly appreciated. Thanks.
- VB Rookie