martin2k

Google
 
Web www.martin2k.co.uk

How do I display pictures using a ListBox?

Question


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


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


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!!


Please fill in the below form if you have any comments or additional information you want to add about the above information.  If you have any Visual Basic 6.0 questions, please visit the ForumAny questions sent using this form will be ignored.

* - Mandatory

*Name: E-mail:

*Comments:

*Please type the following code (your comment will not be accepted without it):


Martin Allen 1999 - 2005.  Last updated Sunday 12 June 2005 04:34:21 PM +0100.