Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2001-08-07
7
Medium Priority
?
262 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 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