Warning - doesn't return a value - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Warning - doesn't return a value

CitizenOlekCitizenOlek Posts: 53Member
Hello,

I just converted a solution from VB.Net 2003 to VB 2005 and received many Warnings all the same.
Here's a sample code:
[code]
Public Property LengthLabel() As Label
Get
End Get
Set(ByVal LengthLabel As Label)
LengthLbl = LengthLabel
End Set
End Property
[/code]
The 'Get - End Get' was added during conversion and this is the Warning:

[color=Red]Warning 82 Property 'LengthLabel' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.[/color]

What is required to correct this Warning?
Thank you.

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hello,
    :
    : I just converted a solution from VB.Net 2003 to VB 2005 and received
    : many Warnings all the same.
    : Here's a sample code:
    : [code]:
    : Public Property LengthLabel() As Label
    : Get
    : End Get
    : Set(ByVal LengthLabel As Label)
    : LengthLbl = LengthLabel
    : End Set
    : End Property
    : [/code]:
    : The 'Get - End Get' was added during conversion and this is the
    : Warning:
    :
    : [color=Red]Warning 82 Property 'LengthLabel' doesn't return a value
    : on all code paths. A null reference exception could occur at run
    : time when the result is used.[/color]
    :
    : What is required to correct this Warning?
    : Thank you.
    :
    You need to fill in the body of the Get part of the declaration.
  • CitizenOlekCitizenOlek Posts: 53Member
    : : Hello,
    : :
    : : I just converted a solution from VB.Net 2003 to VB 2005 and received
    : : many Warnings all the same.
    : : Here's a sample code:
    : : [code]: :
    : : Public Property LengthLabel() As Label
    : : Get
    : : End Get
    : : Set(ByVal LengthLabel As Label)
    : : LengthLbl = LengthLabel
    : : End Set
    : : End Property
    : : [/code]: :
    : : The 'Get - End Get' was added during conversion and this is the
    : : Warning:
    : :
    : : [color=Red]Warning 82 Property 'LengthLabel' doesn't return a value
    : : on all code paths. A null reference exception could occur at run
    : : time when the result is used.[/color]
    : :
    : : What is required to correct this Warning?
    : : Thank you.
    : :
    : You need to fill in the body of the Get part of the declaration.

    Fill it in with what?
    I can't find any help on what this 'Get - End Get' is!
    Can I just use some dummy statement like -Return(0)- ?
    What would you suggest?
  • zibadianzibadian Posts: 6,349Member
    : : : Hello,
    : : :
    : : : I just converted a solution from VB.Net 2003 to VB 2005 and received
    : : : many Warnings all the same.
    : : : Here's a sample code:
    : : : [code]: : :
    : : : Public Property LengthLabel() As Label
    : : : Get
    : : : End Get
    : : : Set(ByVal LengthLabel As Label)
    : : : LengthLbl = LengthLabel
    : : : End Set
    : : : End Property
    : : : [/code]: : :
    : : : The 'Get - End Get' was added during conversion and this is the
    : : : Warning:
    : : :
    : : : [color=Red]Warning 82 Property 'LengthLabel' doesn't return a value
    : : : on all code paths. A null reference exception could occur at run
    : : : time when the result is used.[/color]
    : : :
    : : : What is required to correct this Warning?
    : : : Thank you.
    : : :
    : : You need to fill in the body of the Get part of the declaration.
    :
    : Fill it in with what?
    : I can't find any help on what this 'Get - End Get' is!
    : Can I just use some dummy statement like -Return(0)- ?
    : What would you suggest?
    :
    The Get part is the part, which returns the value of the property. Thus if you have this statement:
    [code]
    MyLabel = SomeObject.LengthLabel();
    [/code]
    MyLabel holds the value of the LengthLabel as set by the Set-part of your property.
Sign In or Register to comment.