Link to home
Start Free TrialLog in
Avatar of cyberp
cyberp

asked on

status of buttons

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 ?
ASKER CERTIFIED SOLUTION
Avatar of BeedleGuis
BeedleGuis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cyberp
cyberp

ASKER

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.
Avatar of cyberp

ASKER

btw, each buttons may have different settings. Different caption and colors.. so ?
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