Passing value through to another form using public property

R

Richard

I'm trying to open a form based on the value that I am passing through
to it. I'm trying to open the Deals form on the basis of a sellerid
that I am trying to pass through to that second form.

At the push of a button on the first form:

Dim cfrmDeals As New frmDeals
cfrmDeals.SellerNo = Convert.ToInt32(txtSellerID.Text)
cfrmDeals.Visible = True
cfrmDeals.Activate()

As you can see this tries to set the SellerNo property on the Deals
form.

The property is set here:

Public Property SellerNo() As Integer
Get
Return SellerNo
End Get
Set(ByVal Value As Integer)
SellerNo = Value
End Set
End Property

However, in practice I keep getting this error message.

"An unhandled exception of type 'System.StackOverflowException'
occurred in Deals.exe."

If I step through it it gets oscillates just going between the 'Set'
line and the 'SellerNo=Value' line.

Anyone help?



Richard
 
C

Chris

Richard said:
I'm trying to open a form based on the value that I am passing through
to it. I'm trying to open the Deals form on the basis of a sellerid
that I am trying to pass through to that second form.

At the push of a button on the first form:

Dim cfrmDeals As New frmDeals
cfrmDeals.SellerNo = Convert.ToInt32(txtSellerID.Text)
cfrmDeals.Visible = True
cfrmDeals.Activate()

As you can see this tries to set the SellerNo property on the Deals
form.

The property is set here:

Public Property SellerNo() As Integer
Get
Return SellerNo
End Get
Set(ByVal Value As Integer)
SellerNo = Value
End Set
End Property

However, in practice I keep getting this error message.

"An unhandled exception of type 'System.StackOverflowException'
occurred in Deals.exe."

If I step through it it gets oscillates just going between the 'Set'
line and the 'SellerNo=Value' line.

Anyone help?



Richard

Public Property SellerNo() As Integer
Get
'Return SellerNo 'No, Can't return a property
Return m_SellerNo
End Get
Set(ByVal Value As Integer)
'SellerNo = Value
'You can't have a variable name the
'same as a property name
m_SellerNo = Value
End Set
End Property
 
R

Richard

Public Property SellerNo() As Integer
Get
'Return SellerNo 'No, Can't return a property
Return m_SellerNo
End Get
Set(ByVal Value As Integer)
'SellerNo = Value
'You can't have a variable name the
'same as a property name
m_SellerNo = Value
End Set
End Property


Thank you Chris!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top