old_school
Member
- Joined
- Jun 9, 2011
- Messages
- 20
- Programming Experience
- 3-5
Two peices of code i suspect causeing the issue but not sure how to fix it:
'Section one causing issue
PrivateSub btnAddDirectory1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddDirectory1.Click
Dim openDir AsNew FolderBrowserDialog
openDir.Description = "Select the directory with the files you wish to add..."
If openDir.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
ForEach filepath AsStringInMy.Computer.FileSystem.GetFiles(openDir.SelectedPath)
IfMy.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".jpg"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".jpeg"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".png"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".bmp"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".gif"Then
filename = My.Computer.FileSystem.GetName(filepath)
IfNot imageCollection.ContainsKey(filename) Then
imageCollection.Add(filename, filepath)
cmbPaths.Items.Add(filename)
EndIf
EndIf
Next
lblCount.Text = "Count: " & (cmbPaths.Items.Count.ToString)
EndIf
EndSub
'section two causeing issue
PrivateSub cmbPaths_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles cmbPaths.SelectedIndexChanged
Dim index AsInteger
index = imageCollection.IndexOfKey(cmbPaths.SelectedItem)
IfNot index = -1 Then
pic.Image = Image.FromFile(imageCollection.Item(cmbPaths.SelectedItem))
EndIf
EndSub
'Section one causing issue
PrivateSub btnAddDirectory1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddDirectory1.Click
Dim openDir AsNew FolderBrowserDialog
openDir.Description = "Select the directory with the files you wish to add..."
If openDir.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
ForEach filepath AsStringInMy.Computer.FileSystem.GetFiles(openDir.SelectedPath)
IfMy.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".jpg"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".jpeg"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".png"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".bmp"Or _
My.Computer.FileSystem.GetFileInfo(filepath).Extension.ToLower = ".gif"Then
filename = My.Computer.FileSystem.GetName(filepath)
IfNot imageCollection.ContainsKey(filename) Then
imageCollection.Add(filename, filepath)
cmbPaths.Items.Add(filename)
EndIf
EndIf
Next
lblCount.Text = "Count: " & (cmbPaths.Items.Count.ToString)
EndIf
EndSub
'section two causeing issue
PrivateSub cmbPaths_SelectedIndexChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles cmbPaths.SelectedIndexChanged
Dim index AsInteger
index = imageCollection.IndexOfKey(cmbPaths.SelectedItem)
IfNot index = -1 Then
pic.Image = Image.FromFile(imageCollection.Item(cmbPaths.SelectedItem))
EndIf
EndSub