Re: Function Warning - Null Reference



Thanks Stephany,

I understand your explanation and what the warning is indicating. In order
to remove the warning I would need to ensure the function does not return a
null pointer. Is there a better syntax available giving a more complete
solution?

My experience comes from VBA and I have just started out in VB and .NET. The
structure and syntax is what I am trying to understand. The best way for me
is to have some good books, try converting some VBA code and visit these
newsgroups. Just wished I started 3 years ago.

Regards

<lord.zoltar@xxxxxxxxx> wrote in message
news:1168556090.645918.315190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Stephany Young wrote:
Return hh & "h " & mm & "m " & ss & "s"


I don't know how much background you have in VB. I'll assume not much.
To clarify:
"Function 'Dec2hms' doesn't return a value on all code paths." means
that a function might not be returning a value along one of its
possible paths of execution, and that a line of code that calls the
function could get a Null Pointer from the function. In VB and VB.NET,
A Sub (Subroutine) is a procedure which never returns a value. A
Function is a procedure that MUST return a value.
To return a value from a function, use the keyword Return followed by
the value or variable that is being returned.
Placing
Return hh & "h " & mm & "m " & ss & "s"
at the end of the function (right above "end function") should fix the
problem.



.



Relevant Pages

  • Re: Function Warning - Null Reference
    ... Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. ... These include String, Integer, DateTime and Boolean ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Function Warning - Null Reference
    ... Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. ... null reference exception could occur at run time when the result is used. ... default value for a String is String.Empty, the default value for an Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Re: PI program again
    ... specifically the multiplication routines can be made faster than ... crtmath.h:22: warning: 'crtcopy32' defined but not used ... Since your file is chock full of inline assembly in GAS syntax, ... other compilers you mentioned. ...
    (comp.programming)
  • Re: not all paths return a value
    ... but what the parser turns it into. ... Which in this case is an entirely different beast. ... see that something is explicitly returned on all code paths in all ... think that the decision whether or not to show the warning should be based ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Try-catch error in Matlab version 7.4
    ... This try-catch syntax will continue to work in R2007a, ... See Release Notes for MATLAB Version 7.4, "Warning Generated by try-catch" ...
    (comp.soft-sys.matlab)