Textbox does not update with new value

I have a sub that will loop through twice on the first time the WirelessBase_RF_CH_Changed is set to false and goes into the first condition. One the second loop the WirelessBase_RF_CH_Changed is set to true with the updated value (the value is there and has been updated) I then assign it to the me.Label (lblBaseRFChannel.text) the me.Label shows the updated value when I place a breakpoint in the debug mode, however after I step through and look at the runtime the value on the screen is the old value from the first loop through

Any ideas?
If WirelessBase_RF_CH_Changed = False Then
                    BaseRFChannel = FindBaseStationArrayInformation(23)
                    BaseRFChannel = BaseRFChannel.Substring(BaseRFChannel.LastIndexOf("..") + 2).Trim()
                    Me.lblBaseRFChannel.Text = BaseRFChannel
                Else
                    Me.lblBaseRFChannel.Text = String.Empty
                    BaseRFChannel = RF_Selected
                    Me.lblBaseRFChannel.Text = BaseRFChannel
                End If

Open in new window

cmdolcetAsked:
Who is Participating?
 
cmdolcetAuthor Commented:
Idle_Mind: The code below seemed to have solved the issue. It seems I wasn;t initializing correctly.





Public F1 As Form1
in some method:
F1.MethodName()

Form1:
in a button click:
Dim F2 As New Form2
F2.F1 = Me
F2.Show()

Open in new window

0
 
kdwoodCommented:

See if this does the trick, add Application.DoEvents after you update the label?

http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx

Regards,

Keith
0
 
cmdolcetAuthor Commented:
No that method on the link about calling the Doevents did not work
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
kdwoodCommented:

Can you post your code where you have your loops set up?  I think we will need to see more to determine what is happening.

0
 
cmdolcetAuthor Commented:

Private Sub UpdateBaseUnit_Mobile_Collect()
        Try
            If Wireless_Base_Updated = False Then
                FindBaseStationArrayInformation = strDataCOM1.Split(New Char() {Chr(13)}, StringSplitOptions.RemoveEmptyEntries)
                grpBaseStation.Enabled = True

                Dim serialnumber As String = FindBaseStationArrayInformation(6)
                serialnumber = serialnumber.Substring(serialnumber.LastIndexOf("..") + 2).Trim()
                Me.lblbaseserial.Text = serialnumber
                Wireless_MC_USB_Base_Serial = serialnumber

                Dim BaseModel As String = FindBaseStationArrayInformation(3)
                BaseModel = BaseModel.Substring(BaseModel.LastIndexOf("..") + 2).Trim()
                Me.lblBaseModel.Text = BaseModel

                Dim FirmwareVer As String = FindBaseStationArrayInformation(4)
                FirmwareVer = FirmwareVer.Substring(FirmwareVer.LastIndexOf("..") + 2).Trim()
                Me.lblBaseFirmwareVer.Text = FirmwareVer
                BaseStation_Version = FirmwareVer

                Dim BaseFirmwareDate As String = FindBaseStationArrayInformation(5)
                BaseFirmwareDate = BaseFirmwareDate.Substring(BaseFirmwareDate.LastIndexOf("..") + 2).Trim()
                Me.lblBaseFirmwareDate.Text = BaseFirmwareDate
                BaseStation_Version_Date = BaseFirmwareDate

                Dim BaseOperationalMode As String = FindBaseStationArrayInformation(8)
                BaseOperationalMode = BaseOperationalMode.Substring(BaseOperationalMode.LastIndexOf("..") + 2).Trim()
                Me.lblBaseOperationalMode.Text = BaseOperationalMode

                Dim BaseDescription As String = FindBaseStationArrayInformation(10)
                BaseDescription = BaseDescription.Substring(BaseDescription.LastIndexOf("..") + 2).Trim()
                Me.lblBaseDescription.Text = BaseDescription

                BaseStationID = FindBaseStationArrayInformation(20)
                BaseStationID = BaseStationID.Substring(BaseStationID.LastIndexOf("..") + 2).Trim()
                Me.lblBaseStationID.Text = BaseStationID

                BaseNetworkID = FindBaseStationArrayInformation(21)
                BaseNetworkID = BaseNetworkID.Substring(BaseNetworkID.LastIndexOf("..") + 2).Trim()
                Old_Base_NetworkID = BaseNetworkID
                Me.lblBaseNetworkID.Text = BaseNetworkID


                BasePanID = FindBaseStationArrayInformation(22)
                BasePanID = BasePanID.Substring(BasePanID.LastIndexOf("..") + 2).Trim()
                Me.lblBasePANID.Text = BasePanID
                Base_PAN_ID_HEX_Value1 = "&H" & BasePanID.Substring(0, 2)
                Base_PAN_ID_HEX_Value2 = "&H" & BasePanID.Substring(2, 2)
                Dim Send_PAN_ID_HEX() As Byte = {Base_PAN_ID_HEX_Value1, Base_PAN_ID_HEX_Value2}
                Send_PAN_ID_Original_HEX = Send_PAN_ID_HEX
                If WirelessBase_RF_CH_Changed = False Then
                    BaseRFChannel = FindBaseStationArrayInformation(23)
                    BaseRFChannel = BaseRFChannel.Substring(BaseRFChannel.LastIndexOf("..") + 2).Trim()
                    Me.lblBaseRFChannel.Text = BaseRFChannel
                Else
                    'Updates the New RF Channel on the Form in Runtime
                    Me.lblBaseRFChannel.Text = String.Empty
                    BaseRFChannel = RF_Selected
                    Me.lblBaseRFChannel.Text = BaseRFChannel
                End If

   End If
        Catch ex As Exception

        End Try
    End Sub

Open in new window

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You sure you're not getting an exception that is being ignored?...

Pop a MessageBox in your Catch block:

        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
0
 
cmdolcetAuthor Commented:
Idle_Mind:I added the MessageBox.Show(ex.ToString) to the catch block and I didn;t receive any errors.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
...and you're sure it's making it into the main If block the second time?

    Private Sub UpdateBaseUnit_Mobile_Collect()
        Try
            If Wireless_Base_Updated = False Then

So "Wireless_Base_Updated" didn't somehow get changed to True?
0
 
cmdolcetAuthor Commented:
yes correct. I stepped through the loop twice and at no point in time did it ever get caught by the catch statement.

I even look at the variable  BaseRFChannel and it contains the updated value I even step a line further and see that the Me.lblBaseRFChannel.Text  is changed to the updated value.

It seems just not on the form the update happens
0
 
x77Commented:
You says WirelessBase_RF_CH_Changed through twice  ?

Is this a Event sub ?.

Is a common mistake think that the Changed Event is raised only when user changes the value. It raises also when your code modify the value.

private Processing_WirelessBase_RF_CH_Changed = false.
Private sub WirelessBase_RF_CH_Changed (...)
   if Processing_WirelessBase_RF_CH_Changed  then return
   Procesing_WirelessBase_RF_CH_Changed= true
   ..... here your code .....
   Processing_WirelessBase_RF_CH_Changed= false
end sub


0
 
cmdolcetAuthor Commented:
x77: Yes this is an event sub.
0
 
cmdolcetAuthor Commented:
x77: I may be misleading everyone. Let me explain in detail at what i am doing and what I want to accomplish. I have (2) forms the first form loads and opens a serial COM port. and keeps it open on the first form I have a textbox that will return a value from the Serial string once the COM Port is open, then I open the second form up from a control button and set a value to the variable. I then want to take that public variable and set the value to my textbox on my first form.

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So you pass the value from the first form to the second form.  Got it.
The user is then changing the value on the second form?
...and you want to update the value on the first form with the new value?

Do you want the update to occur in real-time?...or only when the second form is closed?
0
 
cmdolcetAuthor Commented:
I think I am  trying to invoke a method on the form before the form has finished initializing. However I would like to do it real time.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So when the value in the second form is changed, you want the value in the first form to change at the same time?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Glad you figured it out.  I see you are passing a reference to Form1 into Form2.  =)
0
 
cmdolcetAuthor Commented:
There was a similar issue
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.