Can you elaborate? Your code does not include a return type for the
function, has a clause to set sItem to exactly the same value that it has
during a test (so that elseIf is not needed at all) and doesn't use the
"Return" syntax.
But assuming you corrected these things, what is different about your code
and mine?
VB does include the OrElse logical operand for shortcutting but it wouldn't
be needed here.
"bruce barker" <> wrote in message
news:%...
> this will still fail as vb does not short cut if's , try:
>
>
> Function FixLegal(sItem as String, sPrefix as String)
> if sItem is System.DBNull.Value then
> FixLegal=""
> elseif sItem = "" then
> FixLegal=""
> else
> FixLegal="<i>" & sPrefix & ":</i> " & sItem
> End If
>
> End Function
>
>
>
>
> "Scott M." <s-> wrote in message
> news:...
> > Try changing your code to read like this:
> >
> > Function FixLegal(sItem as String, sPrefix as String) As String
> > if IsDBNull(sItem) or sItem = "" then
> > Return ""
> > else
> > Return "<i>" & sPrefix & ":</i> " & sItem
> > End If
> > End Function
> >
> > **Note that in your original function you never indicated what the
> function
> > return data type was.
> >
> > "Elmo Watson" <> wrote in message
> > news:...
> > > I've got a 'helper' function created, to modify the showing of
database
> > > results:
> > >
> > >
> > > Then, in my DataList:
> > >
> > > <%# FixLegal(Container.DataItem("PrpSection"), "Section") %>
> > >
> > > This works great, unless there's a Null Value in the table for that
> > > field - - when the value is Null - - I get the error in the subject. I
> > > THOUGHT System.DBNull.Value was supposed to take care of this anomaly
> > >
> > > Any ideas?
> > >
> > >
> > >
> > >
> >
> >
>
>
|