Solved

Saving options on a form

Posted on 1998-09-03
16
158 Views
Last Modified: 2010-04-30
I have nine frames on a form & each frame containes 5 array option buttons that change the color of a command button when you click on the option button. Each option button represents a different color.  How do I save the changes each time an option button is selected and the color of the command button changes.  Or at least save the current properties prior to unloading the form?
0
Comment
Question by:tbrasher
  • 11
  • 5
16 Comments
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 100 total points
ID: 1432837
Hi,
You have to use an external file.

use Text file to write and then read the information from
or an INI file or enev the registry..

I hope it helps.

0
 

Author Comment

by:tbrasher
ID: 1432838
Could you give me more information on how to use an external file?  I'm not sure I understand how the color will be saved on the command button.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432839
Hi,
Open file for output ' Write into a text file.


Befor exit the program or in Qureyunload"
 or
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
record your vars
place out file here
End Sub

to record your color use this :
Private Sub Command2_Click()
Dim a
a = Form1.BackColor
MsgBox Hex(a)
End Sub

then print #1 , ' the var in this example  it is a

and when you start the program again
use in Form_Load
1. load the text file
2. restore the colors.
3. place the color in the objects as
label1.backcolor = a

if you need more help here let me know.
0
 

Author Comment

by:tbrasher
ID: 1432840
I have a total of 39 forms, do I need to do this for every form? Also, in the Private Sub Form_Query Unload what is "record your vars"??  Is this the syntax?  When you start the program again in the Form_Load is the 1, 2, and 3 the actual syntax or can I find this in the help files?

I'm new at this and have a deadline of September 12 - I can use all of the help I can get.  I appreciate it!
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432841
Okay I will make a sample project for you and I will post the concept here and
I will give you a URL that you can download the complete project ...Soon..

I am going to work on that a about 1/2 an hour..

0
 

Author Comment

by:tbrasher
ID: 1432842
I appreciate your help - Thanks very much!
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432843
Hi, I am working on the project and will call you soon.

Shay.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432844
Hi, There is a nice progress here stand by in 1/2 an hour.

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432845
Okay the example is here:

and you can download the complete project from http://www.hili.com/~shay/savecolor.zip

============= start ===========

Option Explicit

Private Sub cmdExit_Click()
Dim AColor
AColor = Command1.BackColor
Open "SaveColor.txt" For Output As #1
Print #1, Command1.BackColor 'AColor
Close #1
Unload Me ' You can delete this line
End Sub

Private Sub Form_Load()
Dim ColorLine
Dim AColor
On Error Resume Next
Open "SaveColor.txt" For Input As #1
While Not EOF(1)
    Line Input #1, ColorLine
Wend
Close #1
AColor = ColorLine
Command1.BackColor = AColor
End Sub

' You don't need this Sub. It is an example only.
Private Sub optBlue_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(0, 0, 255)

End Sub
' You don't need this Sub. It is an example only.
Private Sub optGreen_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(0, 255, 0)

End Sub
' You don't need this Sub. It is an example only.
Private Sub optRed_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(255, 0, 0)
End Sub


============ end =============


shay.
0
 

Author Comment

by:tbrasher
ID: 1432846
I tried to get to the URL that you provided but I get an error message saying it doesn't exist.  I went to your homepage but can't find the file to download.  Help!

Thanks so much for helping me out - you're a lifesaver!

Traci
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432847
Okay the url is there now.

code correction:

============== start here =============

Option Explicit

Private Sub cmdExit_Click()
Dim AColor
AColor = Command1.BackColor
Open "SaveColor.txt" For Output As #1
Print #1, Command1.BackColor 'AColor
Close #1
Unload Me ' You can delete this line
End Sub

Private Sub Form_Load()
Dim ColorLine
Dim AColor
Dim ErrorHandler
On Error GoTo ErrorHandler
Open "SaveColor.txt" For Input As #1
While Not EOF(1)
    Line Input #1, ColorLine
Wend
Close #1
AColor = ColorLine
Command1.BackColor = AColor
 
ErrorHandler:
Exit Sub
End Sub

' You don't need this Sub. It is an example only.
Private Sub optBlue_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(0, 0, 255)

End Sub
' You don't need this Sub. It is an example only.
Private Sub optGreen_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(0, 255, 0)

End Sub
' You don't need this Sub. It is an example only.
Private Sub optRed_Click(Index As Integer)
Dim a
 Command1.BackColor = RGB(255, 0, 0)
End Sub


========= end here =========
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432848
the correction is here :

ErrorHandler:
       Exit Sub
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432849
Sorry guys.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432850
You must run the code twice for the first time;
Why?
It create a data (text) file to be use later.

I just hope to GAJS.
0
 

Author Comment

by:tbrasher
ID: 1432851
I tried your sample project and then incorporated it into my project - I'm only on form 1 but it is working so far!  I do have one more question: Do I have to open a seperate file for every command button?  As I said earlier, I have nine frames per page which includes a command button per frame.  Can't thank you enough for all of your help~
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1432852
Well in general if you named the forms with Form1, Form2, Form3...Formn

You can use one data File and specify the form name and it's properties.

Shay.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now