|
nhsal69 wrote: Is this because the second instance is a Sub of the first??
Yes
If you check the XML I posted I solved that.
If the real XML is really like that (having folder nodes in folder nodes) you'll have to use recursion for that.
(have a method call itself and process the folder nodes until it finds no more folder nodes)
|
|
|
|
|
Cool, I have tried to get some of the recursion sorted out, I know what I want it to do, but not sure of the correct form.. Have come up with this so far:
Dim odoc As New System.Xml.XmlDocument
odoc.Load("C:\test\10g_1.xml")
Dim oXmlLog As System.Xml.XmlElement
Dim text As String = ""
Dim FolderSubNode As System.Xml.XmlElement
Dim FolderExist As Boolean
For Each oXmlLog In odoc.SelectNodes("Root")
Dim node As System.Xml.XmlElement
For Each node In oXmlLog.SelectNodes("Folder")
FolderExist = True
Dim fullpath As String = node.Attributes.GetNamedItem("fullpath").Value
Dim subnode = node.SelectSingleNode("Name")
Dim name As String = subnode.InnerText
text &= fullpath & " " & name & Environment.NewLine
Do Until FolderExist = False
For Each node In oXmlLog.SelectNodes("Folder")
If node = "folder" Then FolderExist = True
Next
Dim fullpath As String = node.Attributes.GetNamedItem("fullpath").Value
Dim subnode = node.SelectSingleNode("Name")
Dim name As String = subnode.InnerText
text &= fullpath & " " & name & Environment.NewLine
Loop
Next
Next
Will have a look again later, but any suggestions as to how to go about this would be great..
Cheers
|
|
|
|
|
Thanks for you help, have decided that I'll script something to change the XML file so that it is correctly formed and therefore I won't need to do the recursive searches(Which are proving tricky because of the dodgy formatting)...
I'll post the final code when I get it together..
Thanks again.
|
|
|
|
|
Well I got stuck on the recursion so got a script to tidy up the XML file so that it is reasonably well formed..
But now I have an issue getting one element out,
<sizedata Size= "VALUE" IGNORE THE REST OF THEM/>
here is a fully formed, but shortened XML file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Root Type="TRoot">
<Date>15/10/2009 12:30:08</Date>
<Folder fullpath="C:\" IsFilesNode="0">
<Name>C:\</Name>
<SizeData Size="74609238013" Allocated="72396726232" Wasted="234062016" CDRom="74727184384" Files="116733" Folders="12272" Compression="3"/>
</Folder>
<Folder fullpath="C:\" IsFilesNode="-1">
<Name>[Files]</Name>
<SizeData Size="18745407271" Allocated="18745561088" Wasted="153817" CDRom="18745475072" Files="69" Folders="0" Compression="1"/>
</Folder>
<Folder fullpath="C:\TEMP_\" IsFilesNode="0">
<Name>TEMP_ALAN</Name>
<SizeData Size="15469174140" Allocated="15489126222" Wasted="19886724" CDRom="15478267904" Files="9570" Folders="1832" Compression="1"/>
</Folder>
<Folder fullpath="C:\TEMP_\mp3\" IsFilesNode="0">
<Name>mp3</Name>
<SizeData Size="11504514137" Allocated="11513361814" Wasted="8829863" CDRom="11508457472" Files="4561" Folders="510" Compression="1"/>
</Folder>
</root>
The code I have is below:
<pre>Try
Dim odoc As New System.Xml.XmlDocument
odoc.Load("C:\test\test.xml")
Dim oXmlLog As System.Xml.XmlElement
Dim text As String = ""
For Each oXmlLog In odoc.SelectNodes("Root")
Dim node As System.Xml.XmlElement
For Each node In oXmlLog.SelectNodes("Folder")
Dim fullpath As String = node.Attributes.GetNamedItem("fullpath").Value
Dim SizeData As String = node.Attributes.GetNamedItem("SizeData").Value
Dim subnode = node.SelectSingleNode("Name")
Dim name As String = subnode.InnerText
Dim Date_ As XmlElement = odoc.DocumentElement
Dim Date_time As XmlNodeList = Date_.ChildNodes
Dim Date__time = (Date_time(0).InnerText)
text &= Date__time & " " & fullpath & " " & name & SizeData & Environment.NewLine
Next
Next
Console.Write(text)
Console.Read()
Catch ex As Exception
Console.Write(ex.ToString())
Console.Read()
End Try</pre>
But I can't get the SIZE from SIZEDATA out and into a variable, can you help???
|
|
|
|
|
I have done a bit of VBA before.
Any suggestions to code to find duplicate messages in Microsoft Outlook 2007.
Thanks!
Jwalant Natvarlal Soneji, BE IT, India
|
|
|
|
|
There's a bunch of different ways to do this. But, how you do it is going to depend on what you mean by "duplicate", how your mailbox is organized (folders and such,) and what you want to do with the duplicate messages.
|
|
|
|
|
Thanks.
I would like to search for duplicate mails in the complete mailbox and delete all except 1 mail.
Jwalant Natvarlal Soneji, BE IT, India
|
|
|
|
|
Well then, with that spectacular explanation, none of which answered any questions I asked of you, all I can tell you is this:
Enumerate over the collection of messages in the mailbox, then start another enumeration of the same mailbox starting after the message you just picked up in the first enumeration. Compare the messages, and if they are the same, delete the one you found and continue on. Get the next message and start enumerating every message from that point on, comparing it, ..., and so on, and so on.
|
|
|
|
|
Ohh great!
Thanks for clearing doubts on the logical front, though I had no doubts about the approach.
As I am a beginner with VBA and not in Outlook code, I would like to know something on that front. A pointer to any good learning resource available online should be enough.
Thanks a lot!
Jwalant Natvarlal Soneji, BE IT, India
|
|
|
|
|
how to disconnect my account from mysql server using vb.net 2003 code?
|
|
|
|
|
That depends on what you mean by "disconnect my account". What you've asked doesn't make any sense.
|
|
|
|
|
Hi,
I have one user table in sqlexpress
UserTable
User_ID
User_name
Password
Last_Name
First_Name
last_update
Login form in vb.net.
I can validate user information on login but what I want to do is to have the user to change his/her password the very first time he uses this password.
How can I achieve this solution?
I like to have some sample code
Thanks for your guidance in advance..
PLEASE HELP
|
|
|
|
|
You have given us fairly limited info here, but one option would be this:
When you create a new user, do not put a date in the last_update field (since you are creating, not updating the user).
Then, in the login form, check for NULL in the last_update field. If it's NULL, trigger the password update screen, setting the new password, and inserting a date into the last_update field.
Done!!
|
|
|
|
|
Better yet, add a field to the table: PasswordExpired
I think you can figure out what to do with it.
|
|
|
|
|
Dave Kreskowiak wrote: I think you can figure out what to do with it.
Wouldn't put my money on it
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I wouldn't either. Seriously, I weep for the future of software development.
|
|
|
|
|
Good evening everyone,
in my project I use a 'frames' class which controls the different images of a film. The frames are stored in a generic list, and every time the index changes I raise an own event called 'FrameChanged'. I might have to tell that it's my first attempt to use selfmade EventArgs... and over and over again I run into a 'TargetParameterCountException' without finding an idea why?
Maybe someone of you experienced guys is able to support me with some advice? Here's what I do:
The event is defined in the frames class with
Public Shared Event FrameChanged(ByVal sender As Object, ByVal e As FrameChangedEventArgs) .
The event args are:
Public Class FrameChangedEventArgs
Inherits EventArgs
Public Total As Integer
Public Done As Integer
Public Index As Integer
Public File As String
Public Message As String
Public Sub New(ByVal TotalFrames As Integer, ByVal FramesSoFar As Integer, ByVal Ind As Integer, ByVal filename As String, ByVal msg As String)
MyBase.New()
Total = TotalFrames
Done = FramesSoFar
Index = Ind
File = filename
Message = msg
End Sub
End Class Then the event is raised in the 'Set' part of the index property:
RaiseEvent FrameChanged(Nothing, New FrameChangedEventArgs(Max, value, value, File, String.Empty))
In a form I first define a listener like this:
AddHandler clsFrames.FrameChanged, AddressOf OnFrameChange 'Listener!
And, finally, this is the event handler:
Public Sub OnFrameChange(ByVal sender As Object, ByVal e As FrameChangedEventArgs)
Try
If Me.InvokeRequired Then
Dim dlg As New UpdateCounterDelegate(AddressOf OnFrameChange)
----> Me.Invoke(dlg, New FrameChangedEventArgs(e.Total, e.Done, e.Index, e.File, e.Message))
Else
UpdateGUI(e.Total, e.Done, e.Index, e.File, e.Message)
End If
Catch ex As Exception
MsgBox("Error in the FrameChanged-Event!")
End Try
End Sub
When debugging I find that the error occurs in the marked line above. I'm starting to doubt that I'm able to count to five... Or what else is wrong with my code where this ParameterCount problem might result from?
Thank you in advance,
Michael
p.s. Trying to use 'BeginInvoke' instead results in the same error thrown at the end of the sub, before updating the GUI.
|
|
|
|
|
The parameter mismatch has nothing to do with the number of arguments in the FrameChangedEventArgs constructor. The compiler would catch that and wouldn't even let you build the executable.
The problem is UpdateCounterDelegate. You're passing one parameter to an UpdateCounterDelegate (the FrameChangedEventArgs object). What does that delegate require?
If it's the usual "object as Sender, e as ___EventArgs" format, then you need to add "sender" as an extra parameter in the invoke, before the FrameChangedEventArgs.
|
|
|
|
|
Thank you, Ian, for your constructive support. It works fine now !
Somehow I had assumed that "dlg" would be the sender, so I was sure to have passed sender as well as the EventArgs.
Regards
Michael
|
|
|
|
|
Hi Michael,
Control.Invoke takes TWO parameters: a delegate and a parameters array.
(when no delegate parameters are required, there is a single-parameter overload too).
Examples are plenty, see here[^] for instance.
BTW: you really should find that in no time by looking at the documentation[^].
PS: and you'll have the opportunity to use curly brackets in VB!
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thank you, Luc, for your answer. It's working fine now after inserting the form ('Me') as the sender !
My error was to assume that the delegate itself would function as sender i.e. the first parameter. This error occurred despite looking at samples and the documentation.
Regards
Michael
|
|
|
|
|
i am in need of ID3 decision tree code in vb.net or java for my project.
send me the link to sdeepan_cse@yahoo.com
|
|
|
|
|
Write it yourself. Noone here is just going to hand over their hard work so you get an easy pass at your own job. If you want examples, what's so hard about typing "ID3 decision tree VB.NET" into Google?
|
|
|
|
|
i already tried google search for ID3 decision tree source code in vb.net.
but i did not get any link which require for me.
|
|
|
|
|
Well, it looks like the only source code [^]you're going to get is in C#. You'll have to convert whatever code you find to VB.NET. Again, noone is just going to hand over their work to you.
|
|
|
|