Question on Len function....

  • Thread starter Thread starter Anthony Nystrom
  • Start date Start date
A

Anthony Nystrom

If a field within a db is null, would Len(field) = 0 return true? Null, I
know it will if nothing is in the field which of course is different from
null....

or must my code inc both:

field = value.isdbnull is true or Len("field") = 0

This is a string dt returned withina table within my ds... So I know Len
works when it is not null.... Just wondering if null would be true for Len
as well?

Thanks,

Anthony Nystrom
 
Correction:


if

tblsource.currentrow.item("field") Is DBNull.Value = True or
Len(tblsource.currentrow.item("field")) = 0

return true

Will Len = 0 be true for both Null and empty?

Or can I just use:

Len(tblsource.currentrow.item("field")) = 0

To cover both? (Will it work for null and empty)
 
Hi,


You will get an error trying to get the len of a dbnull

Ken
----------------
 
Even with the or statement?

What would you suggest?

if the dbnull was true would the Len still be run? Are both checked? would
it be better to:

if tblsource.currentrow.item("field") Is DBNull.Value = True then
msgbox(NULL)
elseif Len(tblsource.currentrow.item("field")) = 0 then
msgbox(notNull)
end if
 
So this code will work fine then:

if

tblsource.currentrow.item("field") Is DBNull.Value = True or
Len(tblsource.currentrow.item("field")) = 0 then

return whatever

end if

so if dbnull is false it will evalulate Len... So it won't really error,
correct?
 
Also, since you are answering my questions, for which i really appreiate...
Is there any reason why anh assembly exe should refernce two mscorlib
(different versions) I have a compiled app that when I use version info on
from Jeff Key
Two mscorlib's show up in the dependency list... What do you think?

Here is the link to the version info app:

I do not have any beta frameworks installed....

Here is a link to the app: http://www.sliver.com/dotnet/VersionInfo/


The two versions listed are:

1.0.5000

and

1.0.3300

It seems also that some of my reference assemblies reference both mscorlibs
within them such as the microsoft.applicationblocks.data.dll

Should I be concerned?

One more thing.... After this next question give me your paypal address and
I will donate for your help...

Here it is:

I see an exception dialog popup after the my app closes.... No matter if in
debug or release it shows itself only for a second.... I tried a breakpoint
at the main forms dispose even but it seems to come up after that point,
since when hitting the break point it had not shown up..... once I stepped
it through after dipose there is was quick, I can read just enough to see
that some object isn't set to an instance of some object.... Again it's
fast.... The exception is after come after the main forms dispose event
therefore making it hard to find....


Thanks again,

Anthony Nystrom
 
I usually nest these statements just to make sure that I catch everything
appropriately...

If Not tblsource.currentrow.item("field") Is DBNull.Value Then
If Not Len(If tblsource.currentrow.item("field")) = 0 Then
' You have a valid value
End If
End If
 
Back
Top