Results 1 to 40 of 67

Thread: [RESOLVED] saving control properties/names to text

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] saving control properties/names to text

    I am attempting to save the project controls names and properties to a text file so that the end user can save their project and load it into my app at a later time if they want. I have not completed it yet but would like to know if I am going about it the right way.

    Please advise, and thanks in advance.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     FormBackColor Me
    5. End Sub
    6.  
    7. Private Sub cmdSaveFile_Click()
    8.     m_intFF = FreeFile
    9.     m_strDirectory = "Projects"
    10.     m_SaveProjectFileName = txtFileName.Text
    11.     m_strSDPROJFileName = m_SaveProjectFileName & ".sdproj"
    12.     m_strFileNameLocation = App.Path & "\" & m_strDirectory & "\" & m_strSDPROJFileName
    13.    
    14.     If Len(Dir$(App.Path & "\" & m_strDirectory & "\", vbDirectory)) > 0 Then
    15.         'do nothing because the Projects directory exists
    16.     Else
    17.         MkDir (m_strDirectory)
    18.     End If
    19.    
    20.     'get all the controls on the form
    21.     For Each m_Ctrl In frmMain.Controls
    22.         'if all the controls are a label and they are visible then
    23.         If m_Ctrl Is Label And m_Ctrl.Visible Then
    24.             'lets see how many labels are on the form
    25.             m_intControlCountLBLTEXT = frmMain.lblText.Count
    26.             'now that we have the amounts, lets get the properties of those controls
    27.             'in the control array
    28.             For m_intIndex = 1 To m_intControlCountLBLTEXT
    29.                 With frmMain.lblText(m_intIndex)
    30.                     m_lngBorderStyle = .BorderStyle
    31.                     m_lngTop = .Top
    32.                     m_lngLeft = .Left
    33.                     m_lngHeight = .Height
    34.                     m_lngWidth = .Width
    35.                     m_lngAppearance = .Appearance
    36.                     m_lngBorderStyle = .BorderStyle
    37.                     m_lngBackStyle = .BackStyle
    38.                     m_strCaption = .Caption
    39.                 End If
    40.             Next m_intIndex
    41.         'if all the controls are pictureboxes and they are called
    42.         'pbShape(Index) and are visible then
    43.         ElseIf m_Ctrl Is PictureBox And m_Ctrl.Name = "pbShape" Then
    44.             'lets see how many pictureboxes called pbShape are present
    45.             m_intControlCountPB = frmMain.pb.Count
    46.             'now that we have the amounts, lets get the properties of those controls
    47.             'in the control array
    48.            
    49.         'if all the controls are pictureboxes and they are called
    50.         'pb(Index) and are visible then
    51.         ElseIf m_Ctrl Is PictureBox And m_Ctrl.Name = "pb" Then
    52.             'lets see how many pictureboxes called pb are present
    53.             m_intControlCountPBSHAPE = frmMain.pbShape.Count
    54.             'now that we have the amounts, lets get the properties of those controls
    55.             'in the control array
    56.            
    57.         'now lets get the work area
    58.         ElseIf m_Ctrl Is PictureBox And m_Ctrl.Name = "pbWorkArea" Then
    59.             'should only be one
    60.             m_intControlCountWORKAREA = frmMain.pbWorkArea.Count
    61.             'pbWorkArea is not in a control array so get the properties
    62.             With frmMain.pbWorkArea
    63.                 m_lngHeight = .Height
    64.                 m_lngWidth = .Width
    65.                 m_lngAppearance = .Appearance
    66.                 m_lngBorderStyle = .BorderStyle
    67.             End With
    68.         End If
    69.     Next m_Ctrl
    70.    
    71.     Open m_strFileNameLocation For Output As #m_intFF
    72.     Print #m_intFF, [PRINT THE RELEVANT INFORMATION HERE]
    73.     Close #m_intFF
    74. End Sub
    75.  
    76. Private Sub cmdCancel_Click()
    77.     Unload Me
    78. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width