Accesing a class with properties from another class returns null values
<p>I am making an application that reads values from a meter that is connected to my computer via a serial cable. When i press a button i send a command to the meter and after a few miliseconds i get a response back from the meter with the answer.
I am saving these values to a class that has properties init, so that i can access these values from anywhere.</p>

<p>So my problem is that when i try to get the values back it returns a 'nothing value', and its probably from the initialization i have that has a '<strong>New</strong>' like this'<strong>Dim clsSavedValues As New clsSavedValues</strong>', so when i try to get the values from that property class i create a new instanse and that instanse is empty if am not mistaken.</p>

<p>Ill post the code below but here is how the code flows:
I have 3 classes. MainClass, ProtocolClass, PropertiesClass.
From main i call a method inside ProtocolClass, and that method sends a command to the meter. after a few miliseconds i get a call back inside ProtocolClass anf this method is called '<strong>Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived</strong>' and it saves that return value to the PropertiesClass.
And after the DataReceived method is finished i go back to the MainClass and call another method to get the values from the PropertiesClass that i just saved but they return null. I know they are saved correctly because i can access them if i call them from within the ProtocolClass. But they are null from MainClass.</p>

<p>Here is my code:
<strong>MainClass</strong></p>

<pre><code>'Here i call the ProtocolClass
 Private Sub btnGetLastTransaction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetLastTransaction.Click
        clsProtocol.GetLastTransaction(1, Integer.Parse(tbxTransactionPosition.Text))
    End Sub

'Here i try to read the valies from PropertiesClass
    Public Sub RetrieveMeterSerialNumber()
        Dim clsSavedValues As New clsSavedValues
        lblMeterSerialNumber.Text = clsSavedValues.SaveMeterSerialNumber
    End Sub
</code></pre>

<p><strong>ProtocolClass</strong></p>

<pre><code> Public Sub GetLastTransaction(ByVal destinationAddress As String, ByVal transactionNum As Integer)
        clsSavedValues = New clsSavedValues 'Creating Instance of the properties class
        Try
            Dim v_bodyOfMessage As [Byte]() = {ASCIItoHEX("G"), _
                                               ASCIItoHEX("r")}
            Dim v_bytearray As [Byte]() = ConstructCommand(v_bodyOfMessage)

            SendCommand(v_bytearray)
        Catch ex As Exception
            Console.WriteLine("Meter serial number button click exception: {0}", ex)
        End Try
    End Sub

Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
    If comOpen Then
        Try
            ReDim rx(rxPacketSize)
            Console.WriteLine("RESPONSE")
            For i = 0 To rxPacketSize - 1
                readByte = SerialPort.ReadByte.ToString
                Console.WriteLine(i.ToString &amp; ": " &amp; Conversion.Int(readByte).ToString)
                rx(i) = Conversion.Int(readByte).ToString

                If i &lt;&gt; 0 Then
                    If Convert.ToByte(rx(i)) = vDelimeterFlag(0) Then Exit For
                End If
            Next
            DecodeResponse()
        Catch ex As Exception
            MsgBox("SerialPort_DataReceived Exception: " &amp; ex.Message)
        End Try
    End If
End Sub

Private Sub GetMeterSerialNumber()
    Dim i_startPosition As Integer = 5
    Dim meterSerialNumber As String = GetRemainingPortionOfString(i_startPosition)
    clsSavedValues.SaveMeterSerialNumber = meterSerialNumber
    frmExplorer.RetrieveMeterSerialNumber() 'This is the call to the main class
End Sub
</code></pre>

<p><strong>PropertiesClass</strong></p>

<pre><code>Public Property SaveMeterSerialNumber() As String
    Get
        Return _MeterSerialNumber
    End Get
    Set(ByVal meterSerialNumber As String)
        _MeterSerialNumber = meterSerialNumber
    End Set
End Property
</code></pre>

<p>I want to get the values from the PropertiesClass because ill get more than wan response from the meter and that causes thread issues and i cannot keep track with them. So i save the values in one class and then i want to access them all from that class.
Sorry for the long post, ask me anything you want for clarification</p>