?
Solved

How to save a control (not a usercontrol) property at run-time ?

Posted on 2001-08-07
7
Medium Priority
?
256 Views
Last Modified: 2006-11-17
Hi everybody,

I have a label on a form and I would like to be able to change the label caption and to save this caption at run-time.
So the next time I open the project this new caption appears in the property sheet.

Is it possible ?

Thanks

SCML

0
Comment
Question by:scml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Expert Comment

by:Nitin Sontakke
ID: 6360668
No direct way of doing it in a runtime app. Will have to resort to persistent storage such as Registry. But listen to what others have to say, too.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6360727
what "property sheet" are you refering to.  Do you mean the Property Sheet that is displayed in the VB IDE when you either right click on the control, and select Properties, or sselect the control and press the F4 key?

How is your application setup to display the Property Page?
0
 

Author Comment

by:scml
ID: 6360920
Yes, I mean the property sheet that is displayed in the VB IDE. But it would be only to see if the change on the property has been made.

When the program is run, this property sheet will not show of course.

Thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:Nitin Sontakke
ID: 6360957
The properties that we change during development, they are persisted in the .frm files itself, which are normal text files, which you can even modify / write even using notepad. IDE is just a tool to create these files, nothing more than that.

At runtime, these files are neighter available nor desired to be present so persisting values in these is just out of question, i think.

You will need to resort to some other storage such as Registry or database, your custome text file, anything...

Runtime modifications to such properties will not again be visible in development environment as obviously they are stored at different places.

Come to think of this, if you are going to supply .frms with app (or may be write to it if file exists!), you can write a function to manipulate these files as they are simple text files. However, i discourage you to do so.

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6360992
YOu can't change the values of the properties of the control, set when the program is run, to make those changed values visible in the IDE.  However, you can save the values assigned to a control, at run-time, so that the next time the program is run, that (those) controls are set to the values that they were changed to the previous time the program was run.

I do this all the time, using the SaveSetting and GetSetting functins to save/get the values from the System Registry:


Private Sub Form_Load()
  ..
   .
   .
    Evaluator = Val(GetSetting("MissCap", "Assess", "Evaluator", "-1"))
   
    cboEvaluator.ListIndex = Evaluator
    SubFactor = Val(GetSetting("MissCap", "Assess", "SubFactor", "-1"))
    Question = CInt(GetSetting("MissCap", "Assess", "Question", "1"))
    cboSubFactor.ListIndex = SubFactor
    txtQNum.Text = Question
 

here I am retrieving tha values fo the ListIndex property of two ComboBoxes, as set the time before (if not set, then the default value (-1)) is returned (the values are saved in the Registry as Strings, hence the use of the Val function.

then in the event Handler for the cmdDone button which close the app:

    SaveSetting "MissCap", "Assess", "Company", cboCompany.ListIndex
    SaveSetting "MissCap", "Assess", "Evaluator", cboEvaluator.ListIndex
    SaveSetting "MissCap", "Assess", "SubFactor", cboSubFactor.ListIndex
    SaveSetting "MissCap", "Assess", "Question", txtQNum.Text
  I save the current setting of the Control values, so they can be restored the nexct time the program is run.


Look up the SaveSetting and GetSetting functions in the VB Help System.
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 300 total points
ID: 6361000
YOu can't change the values of the properties of the control, set when the program is run, to make those changed values visible in the IDE.  However, you can save the values assigned to a control, at run-time, so that the next time the program is run, that (those) controls are set to the values that they were changed to the previous time the program was run.

I do this all the time, using the SaveSetting and GetSetting functins to save/get the values from the System Registry:


Private Sub Form_Load()
  ..
   .
   .
    Evaluator = Val(GetSetting("MissCap", "Assess", "Evaluator", "-1"))
   
    cboEvaluator.ListIndex = Evaluator
    SubFactor = Val(GetSetting("MissCap", "Assess", "SubFactor", "-1"))
    Question = CInt(GetSetting("MissCap", "Assess", "Question", "1"))
    cboSubFactor.ListIndex = SubFactor
    txtQNum.Text = Question
 

here I am retrieving tha values fo the ListIndex property of two ComboBoxes, as set the time before (if not set, then the default value (-1)) is returned (the values are saved in the Registry as Strings, hence the use of the Val function.

then in the event Handler for the cmdDone button which close the app:

    SaveSetting "MissCap", "Assess", "Company", cboCompany.ListIndex
    SaveSetting "MissCap", "Assess", "Evaluator", cboEvaluator.ListIndex
    SaveSetting "MissCap", "Assess", "SubFactor", cboSubFactor.ListIndex
    SaveSetting "MissCap", "Assess", "Question", txtQNum.Text
  I save the current setting of the Control values, so they can be restored the nexct time the program is run.


Look up the SaveSetting and GetSetting functions in the VB Help System.
0
 

Author Comment

by:scml
ID: 6361387
Thanks to all !

SCML
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question