Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Statement & Null

Status
Not open for further replies.

KatGraham

Programmer
Feb 12, 2003
58
US
Can anyone tell me why I get an error message: "Invalid use of Null"?

Function AdjsAmt(txtElement, dblTrackAmount, dblOrigAmount) As Double
Select Case txtElement
Case Is = "WCOF"
AdjsAmt = dblTrackAmount - dblOrigAmount
Case Is = "STNY"
AdjsAmt = (dblTrackAmount * 0.32) - (dblOrigAmount * 0.32)
Case Else
AdjsAmt = Null
End Select
End Function
 
An integer cannot be Null.....since you have defined the output of your function as an integer, you are getting your error. Either change the Else portion to some obscure number (such as -9999999) and evaluate for that as your "Null" or chsnge your function retrun type to Variant

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top