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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where is the Nz() function in Visual Basic 6.0??? 2

Status
Not open for further replies.

Sameal

Programmer
Aug 6, 2001
142
US
I recently migrated from programming in VBA behind Access to writing VB 6.0 Client Apps. While working on my current database project I came to a huge stumbling block. It seems VB6 doesn't recognize the function 'nz()'. This function checks to make sure what is supplied to it is not null, and if it is it sends back a zero-based string to replace it. I tried writing my own nz function but I get an invalid use of null error. Can anyone help?

Public Function nz(strValue As String, Optional strChar As String) As String
If Not IsNull(strValue) Then
nz = strValue
Else
nz = strChar
End If
End Function

----- Calling the function like this and get invalid
----- use of null error. 'rs' is my recordset in ADO.

txt1.Text = nz(rs("ECurrentPay"))
 
Try this...

Public Function nz(strValue As Variant) as Variant
If Not IsNull(strValue) Then
nz = strValue
Else
nz = ""
End If
End Function

Works fine with String and Numeric variables.
 
Hi,

Try this:
-----------------------------------------------------------
Public Function nz(strValue As String, Optional strChar As String="") As String
If Not IsNull(strValue) Then
nz = cstr(strValue)
Else
nz = strChar
End If
End Function
-----------------------------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Wahooo thanks =) must of been the variant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top