Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.