|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Learning - displaying selection in pictureboxesProblem 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) KitKat wrote:
Show quoteHide quote > Problem trying to figure this out, using a combo box selection I need to go have you looked at the value of fileName to see if it is valid? I don't > 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) > > 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 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 Show quoteHide quote "KitKat" <kitkat@nospam.com> schreef in bericht news:e%23akaPjTGHA.5908@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) > 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 Show quoteHide quote "KitKat" <kitkat@nospam.com> wrote in message news:e%23akaPjTGHA.5908@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) > Thanks for all the inputs:
Stephany, your assistance really helped I got it all working. So thank you very much!! Show quoteHide quote "Stephany Young" <noone@localhost> wrote in message news:%23oRgPqnTGHA.6084@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" <kitkat@nospam.com> wrote in message > news:e%23akaPjTGHA.5908@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) >> > >
VB.NET - Issues with VB.NET FTP Class to UNIX FTP Server
what's up? reading xml Reading Excel in VB.NET SQL Distinct Null, DBNull, Nothing, VBNullstring Create 30 Day trial version how to avoid broken references when give out projects Building VB.NET Interface definitions from a COM interface Help with Access Database and tables Opening a query in MS Access with parameters using VB.net |
|||||||||||||||||||||||