Howdy, Stranger!

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

Categories

How do I close a form and reopen it with the changes the user makes?

ImDaFrEaKImDaFrEaK Member Posts: 29
I am writing a game and when opening a form certain radio buttons are set automatically in different tabs. They are options that change variables in game play, like weapon choices. When closing the form and reopening the the form the radio buttons go back to preset, I want them to stay where the user put them, but I can't leave the form open. Also, If I close the form and reopen it without declaring it there is disposing error.
Private Sub optionsbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionsbutton.Click
Dim usefrmoptions As New Form()
usefrmoptions.Show()

End Sub
This works but makes new each time with preset, and if i declare usefrmoptions at the beggining of the frmmain then disposing error occurs after opening, closing, then triing to open the frmoptions again.

Comments

  • RSlaydenRSlayden Member Posts: 22
    : I am writing a game and when opening a form certain radio buttons are set automatically in different tabs. They are options that change variables in game play, like weapon choices. When closing the form and reopening the the form the radio buttons go back to preset, I want them to stay where the user put them, but I can't leave the form open. Also, If I close the form and reopen it without declaring it there is disposing error.
    : Private Sub optionsbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionsbutton.Click
    : Dim usefrmoptions As New Form()
    : usefrmoptions.Show()
    :
    : End Sub
    : This works but makes new each time with preset, and if i declare usefrmoptions at the beggining of the frmmain then disposing error occurs after opening, closing, then triing to open the frmoptions again.
    :

    I use a global variable (integer) to hold the value of the RadioButton selected from each group. Only way I know how to do this is using a Module. I'm sure theres a fancy OOP way to do this, but I haven't found it, and this works now. I preset the value in the main form OnLoad sub (not OnActivate). When the dialog form opens its OnActivated code uses a Select statement to set the proper Radiobuttons checked property. The first time through it should have the value preset in the main form. In the OnClick methods for the radiobuttons set the global variable to the index of the radio button. (Remember zero-based). Subsequent calls work properly.
  • ImDaFrEaKImDaFrEaK Member Posts: 29
    Your right... I think im just gonna make an array that will hold all of the settings and keep it controled by the users changes. Then like you said will just load the settings accordingly with the array. Thanx alot :) this will work im sure, your an ace!

  • Andre YoungAndre Young USAMember Posts: 0

    _ < http://forcoder.org /> free ebooks and video tutorials about | Visual Basic .NET, Java, Scratch, PHP, C++, Assembly, Objective-C, R, JavaScript, Swift, C#, Visual Basic, Go, Perl, Ruby, Python, PL/SQL, Delphi, MATLAB, C Julia, Apex, Logo, Scheme, D, Alice, ABAP, SAS, Awk, Dart, Scala, Hack, LabVIEW, Kotlin, COBOL, F#, Clojure, Lua, FoxPro, Bash, Transact-SQL, Erlang, Fortran, Lisp, Prolog, ML, Ada, VBScript, Crystal, Rust | ____

Sign In or Register to comment.