Results 1 to 9 of 9

Thread: Detecting if variables have been changed

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Chicago
    Posts
    202

    Detecting if variables have been changed

    I have a main form that shows another options dialog. Once the options form has been changed, I want properties on the main form to be changed as a result. However, how could I detect if the variables have been changed? BTW, I am sharing the vars in a module. I considered making it detect the vars once the user moves his mouse over the main form, but I want to know if there is a better way. Would a timer be better or is there an even better way? Thanks!
    A programmer is a person who fixes a problem you did not know you had in a way that you cannot understand.

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Detecting if variables have been changed

    I'm confused.. If you have routines in place to change the data, shouldn't they also be able to set the properties elsewhere? Is there a specific type of variable or scenario giving you trouble? Most of the form objects have a .changed or .selectedindexchanged event you can handle..

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Chicago
    Posts
    202

    Re: Detecting if variables have been changed

    I am not just setting properties on the main form. For example, if I want the form to become topmost then immediately not topmost, i had:

    VB Code:
    1. If Vars.popup = "True" Or System.Configuration.ConfigurationSettings.AppSettings("configpopup") = True Then
    2.                 Me.TopMost = True
    3.                 Me.TopMost = False
    4.             End If
    A programmer is a person who fixes a problem you did not know you had in a way that you cannot understand.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Detecting if variables have been changed

    Unless you keep two copies of the settings then you aren't to know whether they've changed. Why don't you just run through all the settings and set whatever properties they correspond to accordingly. That way the ones that have changed will be reflected and the ones that haven't will just stay as they are. The alternative would be to create events attached to those properties, but that's probably more effort than it's worth.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Detecting if variables have been changed

    Quote Originally Posted by conipto
    I'm confused.. If you have routines in place to change the data, shouldn't they also be able to set the properties elsewhere? Is there a specific type of variable or scenario giving you trouble? Most of the form objects have a .changed or .selectedindexchanged event you can handle..

    Bill
    Pardon me if i am incorrect here, but isn't the task ou are performing here redundant?

    why are you making your form topmost, and then not topmost?
    Is this to bring it to the front of the screen but not remain covering everything up? because i do believe .show performs this same action of bring the form to the top, i think you can also use .focus as well.

  6. #6
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Detecting if variables have been changed

    No pal,...
    .show just shows the form..if u use .show again,it doesnt bring the form on top
    Godwin

    Help someone else with what someone helped you!

  7. #7
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Detecting if variables have been changed

    Quote Originally Posted by uniquegodwin
    No pal,...
    .show just shows the form..if u use .show again,it doesnt bring the form on top
    it appears you are correct. the only other way is with an API Call
    nevermind then.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Detecting if variables have been changed

    How about if you made those variables private members of a class, then expose them as properties. Add a variable to the class along the lines of ImChanged, and set it when the Set part of the property is run.

    There are two problems I see with this, which may not be problems for you:
    1) If the property changes from A to B, then changes from B to A, the property will remain effectively unchanged, but the class will not remember that unless it needs to be designed to always remember that the property started at A.

    2) I can't remember the other issue, but I'm sure there was one.
    My usual boring signature: Nothing

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Detecting if variables have been changed

    Quote Originally Posted by uniquegodwin
    No pal,...
    .show just shows the form..if u use .show again,it doesnt bring the form on top
    If you want to bring a form to the front you call Activate on it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width