DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: What is the right way to load/unload image object

  1. #1
    Join Date
    Jun 2005
    Posts
    2

    What is the right way to load/unload image object

    Hi,
    Firstly the scenario:
    1)Load form, Load 20000 new Image
    2)Unload all new image - (e.g Command1_Click(), see code below)
    3)ReLoad 20000 new image - (e.g Command2_Click(), see code below)

    My problem is when I want to reload the new image (item3), the time it takes to load is much longer than loading image at form load / first time load.
    Is there any problem with my Unload procedure? I've already try just using "Unload Image1(pCounter&)" in Unload_All proc, but it still same.
    What is the proper way to Load/Unload image?

    Private Sub Form_Load()
    Load_All
    End Sub

    Private Sub Command1_Click()
    Unload_All
    End Sub

    Private Sub Command2_Click()
    Load_All
    EndSub

    Private Sub Load_All()
    Dim pCounter&
    For pCounter& = 1 To 20000
    Load Image1(pCounter&)
    Next
    End Sub

    Private Sub Unload_All()
    Dim vControl As Control
    For Each vControl In Me.Controls
    Select Case vControl.Name
    Case "Image1"
    If vControl.Index <> 0 Then
    Unload vControl
    End If
    Case Else
    End Select
    Next
    End Sub
    Thanks...

  2. #2
    Join Date
    Jan 2004
    Location
    Alexandria, VA
    Posts
    392
    Do you really need to unload the images first? What happens if you don't?

    If you need to do the unload, then why don't you do it like the load?

    For pCounter& = 1 To 20000
    unLoad Image1(pCounter&)
    Next
    Bob Rouse
    Dimension Data

  3. #3
    Join Date
    Jun 2005
    Posts
    2
    Thanks for answering,
    I need to unload the images first because in my actual application, the number of object that I need to load and reload is different, and I'm using different object too.

    As I mention before, I've tried using "Unload Image1(pCounter&)" but nothing improve.

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    unloading controls is more expensive than loading, I guess because of the resources that VB needs to clean up.
    I suggest you not to unload the 'unused' images, just set the Visibile to False
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center