|
-
Oct 9th, 2005, 07:53 PM
#1
Thread Starter
Banned
[VERY URGENT!]Debug This Code![PLEASE]
I need some help with this script. It's not working....
VB Code:
Private Sub LoadFavorites()
'Set up the treeview
tvFavorites.Nodes.Clear()
tvFavorites.Nodes.Add("Favorites")
tvFavorites.Nodes(0).ImageIndex = 10
tvFavorites.Nodes(0).SelectedImageIndex = 10
Dim FavPath() As String
Dim strsplit() As String
Dim strFav As String
Dim i As Short
Dim oNode As TreeNode
Try
'Load Folders from Favorites Root
FavPath = Directory.GetDirectories(GetFolderPath(SpecialFolder.Favorites))
For Each strFav In FavPath
oNode = New TreeNode
strsplit = Split(strFav, "\", , CompareMethod.Text)
i = UBound(strsplit)
oNode.ImageIndex = 18
oNode.SelectedImageIndex = 19
oNode.Text = strsplit(i)
oNode.Tag = strFav
tvFavorites.Nodes(0).Nodes.Add(oNode)
LoadSubFolders(oNode, strFav)
Next
FavPath = Directory.GetFiles(GetFolderPath(SpecialFolder.Favorites))
For Each strFav In FavPath
If InStr(strFav, ".ini", CompareMethod.Text) Then
Else
oNode = New TreeNode
Dim oFile As New FileInfo(strFav)
strsplit = Split(oFile.Name, ".url", , CompareMethod.Text)
oNode.Text = strsplit(0)
oNode.ImageIndex = 16
oNode.SelectedImageIndex = 16
oNode.Tag = GetUrl(strFav)
tvFavorites.Nodes(0).Nodes.Add(oNode)
End If
Next
Catch ex As Exception
Catch ex As DirectoryNotFoundException
Catch ex As IO.IOException
End Try
oNode = Nothing
End Sub
-
Oct 9th, 2005, 08:18 PM
#2
Re: [VERY URGENT!]Debug This Code![PLEASE]
Where is the error at?? We need more info.. what line?
-
Oct 9th, 2005, 08:32 PM
#3
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
With the tvFavorites.Nodes and the GetFolderPath.
-
Oct 9th, 2005, 08:36 PM
#4
Re: [VERY URGENT!]Debug This Code![PLEASE]
Im guessing this is code you found?? You first need a treeview control on your form, called tvFavorites...
-
Oct 9th, 2005, 08:42 PM
#5
Re: [VERY URGENT!]Debug This Code![PLEASE]
FavPath = Directory.GetDirectories(GetFolderPath(SpecialFolder.Favorites))
Nowhere do you have specialfolder.favorites defined... and the directory is not declared..
Directory example...
VB Code:
Dim MyDirectory As New System.IO.DirectoryInfo("Directory path")
After you declare your directory, THEN you can call .GetDirectories, and .GetFiles..
-
Oct 10th, 2005, 04:36 PM
#6
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
I have a treeview named that. It's the nodes thats messing it up.
-
Oct 10th, 2005, 05:43 PM
#7
Hyperactive Member
Re: [VERY URGENT!]Debug This Code![PLEASE]
Jeez...what is the error?!
"Make it idiot-proof and someone will make a better idiot"
-
Oct 10th, 2005, 05:49 PM
#8
Re: [VERY URGENT!]Debug This Code![PLEASE]
I just copied a treeview in my form, and ran the following code:
VB Code:
'in button click
LoadFavorites()
'sub in form
Private Sub LoadFavorites()
'Set up the treeview
tvFavorites.Nodes.Clear()
tvFavorites.Nodes.Add("Favorites")
tvFavorites.Nodes(0).ImageIndex = 10
tvFavorites.Nodes(0).SelectedImageIndex = 10
End Sub
All worked fine... I repeat.. are you SURE you have a treeview control NAMED tvFavorites in the SAME form you are calling the LoadFavorites sub from?
-
Oct 10th, 2005, 06:04 PM
#9
Re: [VERY URGENT!]Debug This Code![PLEASE]
And here is your code I modified on my machine, currently it loads what is in my "c:\" directory and adds them to the listbox... There were other things not shown in your code, that wern't defined, or defined elsewhere... (certain lines are commented out for a reason, in order to post a working example...)
VB Code:
Private Sub LoadFavorites()
'Set up the treeview
tvFavorites.Nodes.Clear()
tvFavorites.Nodes.Add("Favorites")
tvFavorites.Nodes(0).ImageIndex = 10
tvFavorites.Nodes(0).SelectedImageIndex = 10
Dim FavPath() As String
Dim strsplit() As String
Dim strFav As String
Dim i As Integer
Dim oNode As TreeNode
Dim MyDirectory As System.IO.Directory
Try
'Load Folders from Favorites Root
FavPath = MyDirectory.GetDirectories("C:\")
For Each strFav In FavPath
oNode = New TreeNode()
strsplit = Split(strFav, "\", , CompareMethod.Text)
i = UBound(strsplit)
oNode.ImageIndex = 18
oNode.SelectedImageIndex = 19
oNode.Text = strsplit(i)
oNode.Tag = strFav
tvFavorites.Nodes(0).Nodes.Add(oNode)
'LoadSubFolders(oNode, strFav)
Next
FavPath = MyDirectory.GetFiles("C:\")
For Each strFav In FavPath
If InStr(strFav, ".ini", CompareMethod.Text) = 1 Then
Else
oNode = New TreeNode()
Dim oFile As New System.IO.FileInfo(strFav)
strsplit = Split(oFile.Name, ".url", , CompareMethod.Text)
oNode.Text = strsplit(0)
oNode.ImageIndex = 16
oNode.SelectedImageIndex = 16
'oNode.Tag = GetUrl(strFav)
tvFavorites.Nodes(0).Nodes.Add(oNode)
End If
Next
Catch ex As Exception
'Catch ex As DirectoryNotFoundException
Catch ex As IO.IOException
End Try
oNode = Nothing
End Sub
-
Oct 11th, 2005, 08:17 PM
#10
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
Nice...thanks a bunch. However, it's still having trouble with the tvFavorites.Nodes
-
Oct 11th, 2005, 08:23 PM
#11
Hyperactive Member
Re: [VERY URGENT!]Debug This Code![PLEASE]
what is the error? Tough to fix if we dont know.
-
Oct 11th, 2005, 08:49 PM
#12
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
'Nodes' is not a member of 'System.Windows.Forms.ListView'.
-
Oct 11th, 2005, 09:05 PM
#13
Re: [VERY URGENT!]Debug This Code![PLEASE]
Why are you calling the node property in listview? Listview has no node property only treeview has it.
-
Oct 11th, 2005, 09:15 PM
#14
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
Im not too sure. It was just in the example i found. Any way around it?
-
Oct 11th, 2005, 10:39 PM
#15
Re: [VERY URGENT!]Debug This Code![PLEASE]
Once again... you need to have a TREEVIEW... not a LISTVIEW named tvFavorites.....
If you ADD A TREEVIEW instead of a LISTVIEW it will WORK! lol.. don't know how many times we have to say it...
Notice in the comments in the code...
-
Oct 12th, 2005, 05:48 AM
#16
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
Ok mr.fancy pants. Debug this one.
If Not CurNode.Tag = Nothing Then
Process.Start(CurNode.Tag)
End If
-
Oct 12th, 2005, 05:48 AM
#17
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
-
Oct 12th, 2005, 03:12 PM
#18
Re: [VERY URGENT!]Debug This Code![PLEASE]
Though not in your previous code, the "Tag" is an option for each item of the treeview. They are simply running then current node's tag (a variable they declared) in a Process.Start command...
Example.....
VB Code:
Dim CurNode As TreeNode
CurNode.Tag = tvFavorites.Nodes(0).Tag
-
Oct 12th, 2005, 04:06 PM
#19
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
OK then. So
VB Code:
Dim CurNode As TreeNode
CurNode.Tag = tvfavorites.Nodes(0) .Tag
will do the same as the messed up code that i had?
-
Oct 12th, 2005, 04:14 PM
#20
Re: [VERY URGENT!]Debug This Code![PLEASE]
No, not sure what they are putting as a tag.. the code above doesn't add a tag to the treeview items, so you would get an error.
-
Oct 12th, 2005, 06:34 PM
#21
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
What would be a treeview tag?
-
Oct 13th, 2005, 05:29 PM
#22
Thread Starter
Banned
Re: [VERY URGENT!]Debug This Code![PLEASE]
-
Oct 13th, 2005, 05:47 PM
#23
Re: [VERY URGENT!]Debug This Code![PLEASE]
if you give us a description of what you are trying to accomplish exactly, we can try to give you better suggestions... I'm not sure where this tag code popped up, and why you are trying to use it, as it was not in your original post...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|