• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Saving options on a form

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
tbrasher
Asked:
tbrasher
  • 11
  • 5
1 Solution
 
a111a111a111Commented:
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
 
tbrasherAuthor Commented:
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
 
a111a111a111Commented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
tbrasherAuthor Commented:
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
 
a111a111a111Commented:
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
 
tbrasherAuthor Commented:
I appreciate your help - Thanks very much!
0
 
a111a111a111Commented:
Hi, I am working on the project and will call you soon.

Shay.
0
 
a111a111a111Commented:
Hi, There is a nice progress here stand by in 1/2 an hour.

0
 
a111a111a111Commented:
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
 
tbrasherAuthor Commented:
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
 
a111a111a111Commented:
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
 
a111a111a111Commented:
the correction is here :

ErrorHandler:
       Exit Sub
0
 
a111a111a111Commented:
Sorry guys.
0
 
a111a111a111Commented:
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
 
tbrasherAuthor Commented:
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
 
a111a111a111Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 11
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now