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 ?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
how i i read and write the settings to the file.
And load it later when the form loads.