Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

status of buttons

Posted on 1999-07-12
4
Medium Priority
?
136 Views
Last Modified: 2010-05-02
let's say i have 60 command buttons in a form.
And i would like to save the settings for each one (e.g. caption, backcolor )

how would i be able to do that ?
0
Comment
Question by:cyberp
[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
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
BeedleGuis earned 0 total points
ID: 1524097
dim ctrl as control
dim cntrls as new collection
private type buttn
   Caption as string
   Color as string
end type
DIM BUTTN1 AS buttn
for each ctrl in me.controls
    If TypeOf ctrl Is CommandButton Then
        buttn1.caption = ctrl.caption
        buttn1.color = ctrl.backcolor
        cntrls.add buttn1
    end if
next ctrl

Depending on where you want to save them .. collection or text file or whatever
0
 

Author Comment

by:cyberp
ID: 1524098
let's say i wanna do it in a text file.

how i i read and write the settings to the file.
And load it later when the form loads.
0
 

Author Comment

by:cyberp
ID: 1524099
btw, each buttons may have different settings. Different caption and colors.. so ?
0
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1524100
Open "C:\BTNS.TXT" For Output As #1
Dim ctrl As Control
Dim cntrls As New Collection
For Each ctrl In Me.Controls
    If TypeOf ctrl Is CommandButton Then
        Write #1, ctrl.Caption & "," & ctrl.BackColor
    End If
Next ctrl
Close #1

Then to restore:

Dim strcap As String
Dim strbackcolor As String
Dim ary() As String

Open "C:\BTNs.TXT" For Input As #1
For Each ctrl In Me.Controls
    If TypeOf ctrl Is CommandButton Then
        Input #1, strcap
        ary = Split(strcap, ",")
        ctrl.Caption = ary(0)
        ctrl.BackColor = ary(1)
    End If
Next ctrl
Close #1
End Sub



0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 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