martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

How do I display pictures using a ListBox?


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Question

From: Suzie Latta
Date: Tuesday 15 May 2001 5:14 AM
Subject: visual basic
Question: Hi,

I've got a uni Assignment using visual basic and we can't work out how to do something, and where wondering if you could help.
The problem is we have a list box with three items in it and when you click on the different items a different picture is displayed. We can get it to work for one but not any more!
HELP!!

Suzie

If the pictures are files and the pictures are displayed in the PictureBox, the following code may help you:

Private Sub List1_Click()
Select Case List1.ListIndex
Case 0
Picture1.Picture = LoadPicture("C:\Image0.bmp")
Case 1
Picture1.Picture = LoadPicture("C:\Image1.bmp")
Case 2
Picture1.Picture = LoadPicture("C:\Image2.bmp")
End Select
End Sub


blog comments powered by Disqus

Archived Comments

From: vijaysekaran
Date: Wednesday, May 19, 2004 at 09:24:35
Comments: our coding is very useful in my project

thanks
vijay

 
From: roja
Date: Thursday, July 10, 2003 at 07:07:48
Comments: if you name the files the right way try
Picture1.Picture = LoadPicture("C:\Image" & Index & ".bmp")
 
From: khamlijy rachid
Date: Thursday, June 12, 2003 at 20:31:59
Comments: I NEED MORE INFORMATION ABOUT IT LIST BOX
 
From: nadz
Date: Tuesday, April 29, 2003 at 09:47:18
Comments: hey guys, how can i display the content of my tables in listbox?
 
From: Frank
Date: Saturday, February 15, 2003 at 10:55:14
Comments: Another question, if i want to make a MID playable file as soon as the user click the list1.  How can i do that to load the MID.  Can be use the same way as the pic.
 
Reply:

If you are using the Windows Media Player control, then use this code:

MediaPlayer1.FileName = "C:\WINDOWS\MEDIA\FLOURISH.MID"
 
From: Frank
Date: Saturday, February 15, 2003 at 10:52:16
Comments: Your code in this page save me a lot of strees and it work for my project, a simple one!

Thanks!!


Martin Allen 1999 - 2011.  Last updated Monday 08 August 2011 07:55:26 PM +0100.