dcsimg
Results 1 to 5 of 5

Thread: I'm unable to loop on imagelist in visual basic 6.0

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2018
    Posts
    17

    Question I'm unable to loop on imagelist in visual basic 6.0

    I want to make a program like this 'see one of this two links'..https://ufile.io/y1qm9 or this https://ibb.co/jGobgm
    The program for children ,combines two numbers with a combined output show in the form of a number of apples.
    but I can't loop on imagelist , this is the code/;

    Private Sub Command1_Click()
    ListView1.View = lvwIcon
    Dim i, x, y As Integer
    x = CInt(Text1.Text) + CInt(Text2.Text)

    For y = 1 To x
    ImageList1.ListImages.Add , "s" & y, LoadPicture("C:\Users\pc1\Desktop\2911 copy.jpg")
    Next y
    For i = 1 To x
    ListView1.ListItems.Add , "M" & i, "Apple" & i, i
    Next i
    End Sub

    the error code :
    ImageList must be intialized it can be used.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,234

    Re: I'm unable to loop on imagelist in visual basic 6.0

    I think you should've just kept this thread with your previous thread.

    The error is because you want to first assign the image list to your listview. You do that via the custom properties of the listview. Right click on listivew and choose the properties menu item.

    Now, you don't add a single image multiple times to the imagelist. You just add it once. Doing otherwise is an abuse of system resources IMO.

    Couple things.

    1. If your project will have a specific list of images, you can pre-load them into the imagelist instead of trying to load them at runtime. Right click on the ImageList control and choose the properties menu item. If you are going to do that, and before any images are added, set the picture size within that properties window first.

    2. If adding images at runtime, you will want to set the imagelist picture size before you add any images.

    3. Just FYI. The imagelist can only contain images of one size. If the image doesn't fit that size, it will be stretched to fit. If multiple sizes are needed, you typically use multiple imagelists.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,381

    Re: I'm unable to loop on imagelist in visual basic 6.0

    Which line does the error happen on? When adding to the ImageList or the ListView? It sounds like it happens when you add to the listview... odds are the .ImageList property of the ListView hasn't been set to your ImageView ... if you want the LV to use images from the IV, you need to tell one about the other.

    set ListView1.ImageList = ImageView1

    Then you can use the imageview icons in the list view... you can also set it at design time.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2018
    Posts
    17

    Re: I'm unable to loop on imagelist in visual basic 6.0

    [QUOTE=LaVolpe;5253557]
    Now, you don't add a single image multiple times to the imagelist. You just add it once. Doing otherwise is an abuse of system resources IMO.

    I have only a single image trying to add it to the listview many times as equal to a given number defined by the user. what the code for this ?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2018
    Posts
    17

    Re: I'm unable to loop on imagelist in visual basic 6.0

    I have only a single image trying to add it to the listview many times as equal to a given number defined by the user. what the code for this ?

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
  •  



Featured


Click Here to Expand Forum to Full Width