Results 1 to 7 of 7

Thread: Easy way to clear an array of images in design mode?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2015
    Posts
    57

    Easy way to clear an array of images in design mode?

    I'm working with a large array of Image objects, which I have loaded with actually images in design mode to make it simple to drag them around. Once I'm satisfied with their placement, I want to clean up and clear the images loaded in those controls. Obviously, I can clear them one at a time, but that's really time consuming. Is there a faster way that I'm not thinking of? I considered writing a program to modify the .frm file directly, but I figure that'd only end up messing up the .frx file.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,667

    Re: Easy way to clear an array of images in design mode?

    Add an UserControl to the project.
    Set the property EditAtDesignTime to True.
    Set the property InvisibleAtRunTime to True.
    Add a CommandButton to the UserControl.

    Copy this code to the UserControl code module:

    Code:
    Private Sub Command1_Click()
        Dim an As String
        Dim ctl As Control
        
        an = InputBox("Please enter image array control name")
        If an <> "" Then
            For Each ctl In Parent.Controls
                If TypeName(ctl) = "Image" Then
                    If ctl.Name = an Then
                        Set ctl.Picture = Nothing
                    End If
                End If
            Next
        End If
    End Sub
    Add an instance of the UserControl to the form.
    Right click on the UserControl at design time, and select 'Edit'.
    Click the CommandButton.
    Enter the name of the Image control (for example 'Image1')
    Click OK.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2015
    Posts
    57

    Re: Easy way to clear an array of images in design mode?

    Quote Originally Posted by Eduardo- View Post
    Add an UserControl to the project.
    Set the property EditAtDesignTime to True.
    Set the property InvisibleAtRunTime to True.
    Add a CommandButton to the UserControl.

    Copy this code to the UserControl code module:

    Code:
    Private Sub Command1_Click()
        Dim an As String
        Dim ctl As Control
        
        an = InputBox("Please enter image array control name")
        If an <> "" Then
            For Each ctl In Parent.Controls
                If TypeName(ctl) = "Image" Then
                    If ctl.Name = an Then
                        Set ctl.Picture = Nothing
                    End If
                End If
            Next
        End If
    End Sub
    Add an instance of the UserControl to the form.
    Right click on the UserControl at design time, and select 'Edit'.
    Click the CommandButton.
    Enter the name of the Image control (for example 'Image1')
    Click OK.
    Thanks Eduardo. But I'm not familiar with the EditAtDesignTime or InvisibleAtRunTime properties. Are you referring to VB6?

  4. #4

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2015
    Posts
    57

    Re: Easy way to clear an array of images in design mode?

    Quote Originally Posted by Eduardo- View Post
    Yes.
    Okay, so where can I find these properties. I created a command button but I've never heard of those properties. (Sorry, I'm a programming hobbyist so I only know half there is to know about VB6.) Can you at least point me in the right direction?

    Okay, I figured out how to create the user control and then add an instance of it to my program. When I try to use it, however, it doesn't actually work.
    Last edited by schnel; Apr 29th, 2020 at 10:10 AM.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2015
    Posts
    57

    Re: Easy way to clear an array of images in design mode?

    Thanks a lot. I figured it all out. Now I have a lot to learn about User Controls.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,667

    Re: Easy way to clear an array of images in design mode?

    You can check the description and usage of any property here (click the Properties link).

Tags for this Thread

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