well at the moment you're looping through the controls. Every label you come to you loop through a control array - overwriting a particular set of variables - which probably isn't what you intended to do.
With this code you want to be thinking about how you're going to be loading this information - how are you going to know what properties to assign to which controls etc.
Since all the controls (bar-one) that you want to save are in control arrays - it might make sense to loop through those control arrays one by one. In the example below I've chosen to record the name (and index) of the control at the top and then properties underneath (the reason for this was because of the loading code):Now to load those control properties I'm going to use the CallByName function which allows me to Get/Let/Set properties by knowing their names as a string:VB Code:
Private Sub cmdSaveFile_Click() Dim oCtl As Control ' ' Open m_strFileNameLocation For Output As #m_intFF ' lblText Control Array For Each oCtl In lblText If oCtl.Index Then With oCtl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "BorderStyle", .BorderStyle Print #m_intFF, "Top", .Top ' ' End With End If Next oCtl ' pbShape Control Array For Each oCtl In pbShape If oCtl.Index Then With oCtl ' ' ' ' Close #m_intFF End SubNow there are many ways to approach this - so you may get other (better) suggestions - the code above is just something to think about - feel free to ask any questions.VB Code:
Private Sub cmdLoadFile_Click() Dim oCtl As Control Dim sParts() As String, sLine As String Dim bNewCtl As Boolean Open m_strFileNameLocation For Input As #m_intFF Do Until EOF(m_intFF) Line Input #m_intFF, sLine Select Case True Case bNewCtl sParts = Split(sLine, "|") If UBound(sParts) Then Set oCtl = Me.Controls(sParts(0))(Val(sParts(1))) Load oCtl Else Set oCtl = Me.Controls(sParts(0)) End If bNewCtl = False Case sLine = "###" oCtl.Visible = True Set oCtl = Nothing bNewCtl = True Case Len(sLine) sParts = Split(sLine, "|") CallByName oCtl, sParts(0), VbLet, sParts(1) End Select Loop Close #m_intFF End Sub
Also none of that code has been tested - it should work, but there may be silly errors in it.




Reply With Quote