Click here to Skip to main content
       

Visual Basic

 
GeneralRe: TreeView Find not working Pinmembertreddie7-May-13 8:25 
GeneralRe: TreeView Find not working PinmvpEddy Vluggen7-May-13 9:06 
GeneralRe: TreeView Find not working Pinmembertreddie7-May-13 11:57 
GeneralRe: TreeView Find not working PinmvpEddy Vluggen8-May-13 7:01 
QuestionView the changes in the database by DATA SET... PinmemberVb Rnd4-May-13 6:23 
AnswerRe: View the changes in the database by DATA SET... PinmvpEddy Vluggen5-May-13 8:38 
QuestionPathTooLongException and Solutions? [modified] Pinmembertreddie3-May-13 9:38 
AnswerRe: PathTooLongException and Solutions? PinmvpEddy Vluggen5-May-13 9:43 
GeneralRe: PathTooLongException and Solutions? Pinmembertreddie5-May-13 9:50 
GeneralRe: PathTooLongException and Solutions? PinmvpEddy Vluggen5-May-13 10:04 
QuestionHow do i save all opened windows PinmemberMember 46241693-May-13 3:16 
AnswerRe: How do i save all opened windows PinmemberGuyThiebaut3-May-13 4:23 
QuestionHow do i save all opened windows PinmemberMember 46241693-May-13 2:56 
QuestionTry Catch does not Execute Catch code [modified] Pinmembertreddie2-May-13 18:31 
Hi all.
 
I was trying this TreeView demo and ran into a situation where a Try Catch block will not pass execution onto the Catch code. The error is "Drive not ready" when attempting to access a:\. That is easy enough to understand...I have no floppy on my system. But why does the error handler not pass the error to the Catch area?
 
Many thanks for any advice!
 
Here is the demo:
 
A form just has a TreeView and a button on it. The demo populates a TreeView with the directories of my file system:
 
Public Class Form1
 
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Get a list of drives
    Dim drives As System.Collections.ObjectModel.ReadOnlyCollection(Of IO.DriveInfo) = My.Computer.FileSystem.Drives
    Dim rootDir As String = String.Empty
 
    'Now loop thru each drive and populate the treeview:
    For i As Integer = 0 To drives.Count - 1
      rootDir = drives(i).Name
 
      'Add this drive as a root node:
      TreeView1.Nodes.Add(rootDir)
 
      'Populate this root node:
      PopulateTreeView(rootDir, TreeView1.Nodes(i))
    Next
 
  End Sub
 
  Private Sub PopulateTreeView(ByVal dir As String, ByVal parentNode As TreeNode)
    Dim folder As String = String.Empty
 
    Try
      Dim folders() As String = IO.Directory.GetDirectories(dir)
 
      If folders.Length <> 0 Then
        Dim childNode As TreeNode = Nothing
 
        For Each folder In folders
          childNode = New TreeNode(folder)
          parentNode.Nodes.Add(childNode)
          PopulateTreeView(folder, childNode)
        Next
      End If
 
    Catch ex As UnauthorizedAccessException
      parentNode.Nodes.Add(folder & ": Access Denied")
 
    End Try
 
  End Sub
 
End Class


modified 3-May-13 3:17am.

AnswerRe: Try Catch does not Execute Catch code PinmvpRichard MacCutchan2-May-13 21:41 
GeneralRe: Try Catch does not Execute Catch code Pinmembertreddie2-May-13 22:02 
QuestionMethod signature does not match delegate - thread safe PinmemberMember 100187622-May-13 7:12 
AnswerRe: Method signature does not match delegate - thread safe PinprofessionalRichard Deeming2-May-13 8:21 
GeneralRe: Method signature does not match delegate - thread safe PinmemberMember 100187622-May-13 11:00 
GeneralRe: Method signature does not match delegate - thread safe PinmemberAlan N2-May-13 12:26 
QuestionTrouble passing arguments to System.Diagnostics.Process.Start Pinmembersavedlema2-May-13 0:07 
AnswerRe: Trouble passing arguments to System.Diagnostics.Process.Start [modified] PinmvpRichard MacCutchan2-May-13 1:07 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start PinprofessionalRichard Deeming2-May-13 1:23 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start PinmvpRichard MacCutchan2-May-13 1:27 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start Pinmembersavedlema2-May-13 8:06 
AnswerRe: Trouble passing arguments to System.Diagnostics.Process.Start PinmvpEddy Vluggen2-May-13 5:07 
AnswerRe: Trouble passing arguments to System.Diagnostics.Process.Start PinmemberAlan N2-May-13 5:44 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start Pinmembersavedlema2-May-13 8:01 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start PinmemberAlan N2-May-13 8:17 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start Pinmembersavedlema3-May-13 0:54 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start PinmemberAlan N3-May-13 2:57 
GeneralRe: Trouble passing arguments to System.Diagnostics.Process.Start [modified] Pinmembersavedlema3-May-13 4:24 
QuestionWord VBA: quickly checking if table is uniform from 3rd row on PinmemberBart Van Eyndhoven1-May-13 23:08 
AnswerRe: Word VBA: quickly checking if table is uniform from 3rd row on PinprofessionalKenneth Haugland2-May-13 2:28 
QuestionRe: Word VBA: quickly checking if table is uniform from 3rd row on PinprofessionalKenneth Haugland2-May-13 2:37 
AnswerRe: Word VBA: quickly checking if table is uniform from 3rd row on PinmemberBart Van Eyndhoven2-May-13 4:23 
GeneralRe: Word VBA: quickly checking if table is uniform from 3rd row on PinprofessionalKenneth Haugland2-May-13 4:54 
GeneralRe: Word VBA: quickly checking if table is uniform from 3rd row on PinmemberBart Van Eyndhoven2-May-13 21:51 
AnswerRe: Word VBA: quickly checking if table is uniform from 3rd row on PinmemberTnTinMn4-May-13 5:33 
QuestionVB Macro one sheet is corrupt Pinmembersaurabhrahulsharma1-May-13 16:59 
AnswerRe: VB Macro one sheet is corrupt Pinmemberjan212r1-May-13 20:31 
AnswerRe: VB Macro one sheet is corrupt PinprofessionalKenneth Haugland2-May-13 1:24 
QuestionHow can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? PinmemberVivek1987agarwal1-May-13 10:03 
AnswerRe: How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? Pinmemberdusty_dex1-May-13 11:24 
GeneralRe: How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? PinmemberVivek1987agarwal1-May-13 20:49 
GeneralRe: How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? PinmvpRichard MacCutchan1-May-13 21:24 
GeneralRe: How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? PinmemberVivek1987agarwal1-May-13 21:30 
GeneralRe: How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD ??? PinmvpRichard MacCutchan1-May-13 22:04 
QuestionSQL working in SQLPlus but not returning rows in VB.net using Oracle.OLEDB provider Pinmemberliona1-May-13 3:14 
AnswerRe: SQL working in SQLPlus but not returning rows in VB.net using Oracle.OLEDB provider PinprofessionalSimon_Whale1-May-13 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 30 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid