Learning - displaying selection in pictureboxes

K

KitKat

Problem trying to figure this out, using a combo box selection I need to go
to each folder, Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,and Cam 8 and display each
picture (from selection) from each folder and display in pictureboxes
pcbCam1, pcbCam2, pcbCam4, pcbCam6, pcbCam7, and pcbCam8.

So far the code works for one picture box not the others. Also when I
reenter a different date the counter (+1) messes up....HELP



Dim dt As DateTime = DateTime.ParseExact(cmbDate.Items(cmbDate.Selected
Index), "MMMM d, yyyy", Nothing)
Dim folder As String = "C:\Projects\Dar\Queue Review Files\" & dt.Month &
"-" & dt.Day & "\Cam " & Me.cmbDate.SelectedIndex + 1

Dim fileName As String = folder & "\" & Me.cmbTime.Text

Me.pcbCam1.Image = Image.FromFile(fileName)
 
G

Guest

KitKat said:
Problem trying to figure this out, using a combo box selection I need to go
to each folder, Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,and Cam 8 and display each
picture (from selection) from each folder and display in pictureboxes
pcbCam1, pcbCam2, pcbCam4, pcbCam6, pcbCam7, and pcbCam8.

So far the code works for one picture box not the others. Also when I
reenter a different date the counter (+1) messes up....HELP



Dim dt As DateTime = DateTime.ParseExact(cmbDate.Items(cmbDate.Selected
Index), "MMMM d, yyyy", Nothing)
Dim folder As String = "C:\Projects\Dar\Queue Review Files\" & dt.Month &
"-" & dt.Day & "\Cam " & Me.cmbDate.SelectedIndex + 1

Dim fileName As String = folder & "\" & Me.cmbTime.Text

Me.pcbCam1.Image = Image.FromFile(fileName)

have you looked at the value of fileName to see if it is valid? I don't
see any counter in your code.

Also, it's simpler to get the selected item this way.

Dim dt As DateTime = DateTime.ParseExact(cmbDate.SelectedItem.ToString,
"MMMM d, yyy", Nothing)

Chris
 
C

Cor Ligthert [MVP]

KitKat,

Not only globalization gives problems with dates. (Date and time
representation are not used in an equal way in the world. That in the way we
note them. If we start talking about speaking them there is even more
difference).

However, your combobox returns a string. Don't therefore thinking on my
previous sentence try to bring it back to a DateTime there is no need for
that.

Just use the split in your case to get the elements you want.

dim TheDateItems() as string = cmbDateItems.split(" "c)

It is not important for you that it are date elements, it are just some
values to fill in your path string.

I hope this helps,

Cor
 
S

Stephany Young

From what you appear to be attemptinf to do, one must assume that the
drop-down portion of your ComboBox displays a list of dates and that when an
item in the drop-list is selected, ALL 8 pictureboxes should display the
image for the selected date and specified time from the corresponding
directory. If that is the case then what you need could be as simple as:

Dim folder As String = "C:\Projects\Dar\Queue Review Files\" &
DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy",
Nothing).ToString("M-d") & "\Cam{0}\" & cmbTime.Text

For i As Integer = 1 To 8
Select Case i
Case 1
pcbCam1.Image = Image.FromFile(String.Format(folder, i))

Case 2
pcbCam2.Image = Image.FromFile(String.Format(folder, i))

Case 3
pcbCam3.Image = Image.FromFile(String.Format(folder, i))

Case 4
pcbCam4.Image = Image.FromFile(String.Format(folder, i))

Case 5
pcbCam5.Image = Image.FromFile(String.Format(folder, i))

Case 6
pcbCam6.Image = Image.FromFile(String.Format(folder, i))

Case 7
pcbCam7.Image = Image.FromFile(String.Format(folder, i))

Case 8
pcbCam8.Image = Image.FromFile(String.Format(folder, i))
End Select
Next
 
K

KitKat

Thanks for all the inputs:

Stephany, your assistance really helped I got it all working. So thank you
very much!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top