• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

URGENT: Display selected image files onto 6 PictureBoxes and .....


i hav 2 FileListBoxes with four command buttons. I hav done the part on selecting the file combo type, drive path, file directory & text box to display the files. BUT, i do not know how to do the following
below problems in VB6. Pls help me. Its urgent.

Button 1 -> Select one highlighted file in FileListBox1 & make them appear in FileListBox2.
Button 2 -> Select all files in FileListBox1 & make them appear in FileListBox2.
Button 3 & 4 is the reverse. De-selecting files frm FileListBox2 back to FileListBox1.

Once the file selected appear over at FileListBox2, the one at FileListBox1 will disappear & vice versa. Btw, Listbox or FileListBox better for this case?

After u hav selected the files(images files) which are now in FileListBox2, there is a "OK" command button that will load the 1st 6 image files onto 6 PictureBoxes in another FORM. How to load the 1st 6 image files onto 6 PictureBoxes with a "NEXT 6" & "BACK" buttons to traverse 6 pictures at a time down the list of image files selected.

How to invoke the Printer Properties window where u can configure the settings of the printer tat is attached to yur PC & send the 6 pictures on display to print? Pls help me out. Any sample code are most welcome. Thanxs alot.

1 Solution
Filelistboxes interact with OS, so if you want a file disappear from filelistbox you should erase the file from file system. It is better use list boxes and a visible=false filelistbox, fill your first listbox from lists of filelistbox. And play with listboxes.
There is an object printer use its properties to set and select printer object. I am adding an MSDN document part to select printer, hope helps.

Using the Printers Collection

The Printers collection is an object that contains all the printers that are available on the operating system. The list of Printers are the same as those available in the Print Setup dialog box or the Windows Control Panel. Each printer in the collection has a unique index for identification. Starting with 0, each printer in the collection can be referenced by its number.

Regardless of which printing method you use, all printed output from a Visual Basic application is directed to the Printer object, which initially represents the default printer specified in the Windows Control Panel. However, you can set the default printer to any one member in the Printers collection.

To select the printer from the collection, use the following syntax:

Set Printer = Printers(n)

The following statements print the device names of all the printers on the operating system to the Immediate window:

Private Sub Command1_Click()
Dim x As Printer
   For Each x In Printers
      Debug.Print x.DeviceName
End Sub

Note   You cannot create new instances of the Printer object in code, and you cannot directly add or remove printers from the Printers collection. To add or remove printers on your system, use the Windows Control Panel.

On the subject of displaying pictures...

Suppose your pictureboxes are on Form2 and strPathOfPicture is the file path (eg. C:\Pictures\picture.bmp)

Private Sub Command1_Click()
'Load and show the picture form
'Load the picture into the box
Form2.Picture1 = LoadPicture(strPathOfPicture)
'now do the same for the remaining five boxes
End Sub

what you can do is have a 6-item string array, each item being a picture path. then, at the end of the command1_click() sub you can reassign the values to the next six from the filelistbox

hope this helps...
MegadethAuthor Commented:
To: otherviceroy

thanxs for yur help.i need to ask u something. hope u dun mind. i created 6 PictureBox on form2 as array like Picture(0), Picture(1) etc. So tat is not neccessary if we are going to hav a string array for the PathofPicture, rite?

pardon me, becos im new to Visual Basic. Im only very average in C++ programming. Therefore, alot of things in VB, i need some help. im not really sure abt how u assign all the files selected in the fileListBox2 as string arrays & then assign the next six down the list. Do i hav to use a For Loop to assign the next 6?

Btw, wats the best way to solve my 1st problem regarding selecting the files tat appear in fileListBox1 after i had browse to the folder that i wanted (i hav done the drive path, directory path & file type) and then selecting the files simply by clicking on it using mouse & then with a command_button1, the file will then appear on fileListBox2. The two fileListBox are beside each other on form1. Tats why, the files selected & now appearing in filelistBox2 will then be displayed in sets of 6 in those PictureBox on form2.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

MegadethAuthor Commented:
To iozturk:

thanxs for the code for invoking the Printer Properties. As for the file selection & de-selection between the 2 fileListbox. u recommended ListBox, issit becos its easier to use AddItem to add the files selected from the 1st filebox?

Btw, the 2 listbox are side by side. The left listbox has all the files of the current folder i hav browse using combobox, drivelistbox & dirlistbox and then when i click the file & then assign a command_button to make the file appear on the right listbox, i jus want the right listbox to hav tat file name & its path of file, so tat i can proceed to display them on the 2nd form. The selected file tat appears on the right side, will disappear on the left side. No files are deleted physically. How to solve it? Thanxs.

MegadethAuthor Commented:
To: otherviceroy

i should use ListIndex for either listbox or filelistbox if i wanna hav a string array for the strPathofPicture, rite?
Hi Megadeth,
This old question (QID 20568473) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
MegadethAuthor Commented:
thanxs for yur help. As u only answer part of the question, i gave 3/4 of the total points. Hope tats alrite wif u cos im in need of points to ask questions as im on a very tight schedule to complete a VB assignment.sorry, hope u understand. thanxs once again for yur help.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now