Updating the Registry With Visual Basic

Before I unload my main form, I am trying to store my values from my txtboxes into the registry. It does not work when I unload the other forms. Would you happen to know how to correct this problem?



Here's the code:



Private Sub Form_Unload(Cancel As Integer)

IPSi = txtIPSi(0).Text

IPSm = txtIPSm(1).Text





MSVi = txtMSVi(0).Text

MSVm = txtMSVm(1).Text



MCVi = txtMCVi(0).Text

MCVm = txtMCVm(1).Text



SaveSetting TsmReg, "Values", "IPSi", IPSi

SaveSetting TsmReg, "Values", "IPSm", IPSm

SaveSetting TsmReg, "Values", "MCVi", MCVi

SaveSetting TsmReg, "Values", "MCVm", MCVm

SaveSetting TsmReg, "Values", "MSVi", MSVi

SaveSetting TsmReg, "Values", "MSVm", MSVm



Dim i As Integer



'close all sub forms

For i = Forms.Count - 1 To 1 Step -1

Unload Forms(i)

Next

End Sub








Comments

  • : Before I unload my main form, I am trying to store my values from my txtboxes into the registry. It does not work when I unload the other forms. Would you happen to know how to correct this problem?

    :

    : Here's the code:

    :

    : Private Sub Form_Unload(Cancel As Integer)

    : IPSi = txtIPSi(0).Text

    : IPSm = txtIPSm(1).Text

    :

    :

    : MSVi = txtMSVi(0).Text

    : MSVm = txtMSVm(1).Text

    :

    : MCVi = txtMCVi(0).Text

    : MCVm = txtMCVm(1).Text

    :

    : SaveSetting TsmReg, "Values", "IPSi", IPSi

    : SaveSetting TsmReg, "Values", "IPSm", IPSm

    : SaveSetting TsmReg, "Values", "MCVi", MCVi

    : SaveSetting TsmReg, "Values", "MCVm", MCVm

    : SaveSetting TsmReg, "Values", "MSVi", MSVi

    : SaveSetting TsmReg, "Values", "MSVm", MSVm

    :

    : Dim i As Integer

    :

    : 'close all sub forms

    : For i = Forms.Count - 1 To 1 Step -1

    : Unload Forms(i)

    : Next

    : End Sub

    :

    :

    :

    :





    In each form's unload event, add code to save the settings on it.



    Private Sub Form_Unload(...)



        'Save the settings here...



    End Sub


  • That is where I placed the savesettings line of code. For some reason, no matter how I code the unload all forms, my settings will no longer be saved to the registry.





    : : Before I unload my main form, I am trying to store my values from my txtboxes into the registry. It does not work when I unload the other forms. Would you happen to know how to correct this problem?

    : :

    : : Here's the code:

    : :

    : : Private Sub Form_Unload(Cancel As Integer)

    : : IPSi = txtIPSi(0).Text

    : : IPSm = txtIPSm(1).Text

    : :

    : :

    : : MSVi = txtMSVi(0).Text

    : : MSVm = txtMSVm(1).Text

    : :

    : : MCVi = txtMCVi(0).Text

    : : MCVm = txtMCVm(1).Text

    : :

    : : SaveSetting TsmReg, "Values", "IPSi", IPSi

    : : SaveSetting TsmReg, "Values", "IPSm", IPSm

    : : SaveSetting TsmReg, "Values", "MCVi", MCVi

    : : SaveSetting TsmReg, "Values", "MCVm", MCVm

    : : SaveSetting TsmReg, "Values", "MSVi", MSVi

    : : SaveSetting TsmReg, "Values", "MSVm", MSVm

    : :

    : : Dim i As Integer

    : :

    : : 'close all sub forms

    : : For i = Forms.Count - 1 To 1 Step -1

    : : Unload Forms(i)

    : : Next

    : : End Sub

    : :

    : :

    : :

    : :

    :

    :

    : In each form's unload event, add code to save the settings on it.

    :

    : Private Sub Form_Unload(...)

    :

    : 'Save the settings here...

    :

    : End Sub

    :






  • I fixed it by removing the settings coding from the Unload event and placing it in the Form Active event.



    When I put it in the unload event, my settings were being set to 0 before the entire program terminated. But when I placed it into the Form Active event, the settings were set each time that the main form became active.



    I would like to thank you for the code that allows me to Unload each form within the project

    simultaniously.





    Thank you again,



    Timbo

    Vinestim@yahoo.com





    : That is where I placed the savesettings line of code. For some reason, no matter how I code the unload all forms, my settings will no longer be saved to the registry.

    :

    :

    : : : Before I unload my main form, I am trying to store my values from my txtboxes into the registry. It does not work when I unload the other forms. Would you happen to know how to correct this problem?

    : : :

    : : : Here's the code:

    : : :

    : : : Private Sub Form_Unload(Cancel As Integer)

    : : : IPSi = txtIPSi(0).Text

    : : : IPSm = txtIPSm(1).Text

    : : :

    : : :

    : : : MSVi = txtMSVi(0).Text

    : : : MSVm = txtMSVm(1).Text

    : : :

    : : : MCVi = txtMCVi(0).Text

    : : : MCVm = txtMCVm(1).Text

    : : :

    : : : SaveSetting TsmReg, "Values", "IPSi", IPSi

    : : : SaveSetting TsmReg, "Values", "IPSm", IPSm

    : : : SaveSetting TsmReg, "Values", "MCVi", MCVi

    : : : SaveSetting TsmReg, "Values", "MCVm", MCVm

    : : : SaveSetting TsmReg, "Values", "MSVi", MSVi

    : : : SaveSetting TsmReg, "Values", "MSVm", MSVm

    : : :

    : : : Dim i As Integer

    : : :

    : : : 'close all sub forms

    : : : For i = Forms.Count - 1 To 1 Step -1

    : : : Unload Forms(i)

    : : : Next

    : : : End Sub

    : : :

    : : :

    : : :

    : : :

    : :

    : :

    : : In each form's unload event, add code to save the settings on it.

    : :

    : : Private Sub Form_Unload(...)

    : :

    : : 'Save the settings here...

    : :

    : : End Sub

    : :

    :

    :

    :






  • : I fixed it by removing the settings coding from the Unload event and placing it in the Form Active event.

    :

    : When I put it in the unload event, my settings were being set to 0 before the entire program terminated. But when I placed it into the Form Active event, the settings were set each time that the main form became active.

    :

    : I would like to thank you for the code that allows me to Unload each form within the project

    : simultaniously.

    :

    :

    : Thank you again,

    :

    : Timbo

    : Vinestim@yahoo.com

    :


Sign In or Register to comment.

Howdy, Stranger!

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

Categories