Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42326

VS 2010 Public Property help

$
0
0
I need some help figuring out how to use properties:
I have this property in a class:
Code:

Public Class ErvID

    Private BidID As String

    Public Property ErvID() As String
        Get
            Return BidID
        End Get
        Set(ByVal value As String)
            BidID = value
        End Set
    End Property
End Class

I set the property like this in a different class: Class frmSearch

Code:

Private Sub BidBindingSource_PositionChanged(sender As Object, e As System.EventArgs) Handles BidBindingSource.PositionChanged

        Dim objBidID As ErvID

        Dim newID As String

        objBidID = New ErvID

        Dim row As ERVDataSet.BidRow
        row = CType(CType(Me.BidBindingSource.Current, DataRowView).Row, ERVDataSet.BidRow) ''Get the current row of the bid DGV

        Dim ErvID As String = row.BidID ''Get the BidID from DGV

        objBidID.ErvID = ErvID ''Set value to property


        newID = objBidID.ErvID ''Get value from property

and I want to access the property from even another class: Class frmExempt


Code:

  ' Dim objBidID As ErvID

            'Dim BidID As String



            'BidID = objBidID.ErvID

My problem is with the last set of code:
I've tried:
Dim objBidID as ErvID
objBidID = New ErvID '' But this starts a new instance of ErvID class hence the value in the property is gone

and the above code block simply doesn't return the property in the frmExempt form. I know the property is works in the frmSearch Class but whay can't I get it using the same instance of the ErvID class to work in the frmExempt class.

So I have 2 forms: frmSearch and frmExempt and 1 Class ErvID. ErvID is where the property is located. and I need to Set its value from frmSearch and Get the properties value from frmExempt. If this makes any sense?

I've read Shaggys tut on this but am still lost. can someone help me understand this. BTY there is a easier way using a constructor, passing in the id when frmExempt is created but I am really confussed on that approach, and I'm using the default instance anyway.

Viewing all articles
Browse latest Browse all 42326


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>