469,645 Members | 1,150 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Learning - displaying selection in pictureboxes

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)
Mar 23 '06 #1
4 1245
KitKat wrote:
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
Mar 23 '06 #2
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

"KitKat" <ki****@nospam.com> schreef in bericht
news:e%****************@TK2MSFTNGP14.phx.gbl...
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)

Mar 23 '06 #3
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
"KitKat" <ki****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
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)

Mar 23 '06 #4
Thanks for all the inputs:

Stephany, your assistance really helped I got it all working. So thank you
very much!!
"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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
"KitKat" <ki****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
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)


Mar 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Scott Mackay | last post: by
36 posts views Thread by utab | last post: by
3 posts views Thread by manxie | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.