|
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.
|
|
|
|
|
Now you have published your email address I bet you get lots of 'code'.
You are on the wrong site, try rentacoder.com and pay for it - or admit you will fail your course/shouldn't have taken the job (delete as appropriate)
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hello,
Wow, it's been 1 week, yes 1 week before i request any help about this nightmare.
It's seems almost impossible to have a simple VB code for what i want.
My goal :
- Query 30 printers with SNMP so i can retrieve their Page Counter.
I made a batch for that with the util "snmpget". So simple, but i would like to perform it all in Excel so it would be better to transfer it in VB.
I tried so many things, third party DLL, API, Winsock, WMI, SNMP... Some codes works but not everything, others simply don't, well...
I would like to work with this bunch of code :
strTargetSnmpDevice = "192.168.1.20"
Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")
Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"
Set colIfTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_ifTable", , _
objWmiNamedValueSet)
For Each objInterface In colIfTable
WScript.Echo "ifIndex [Key]: " & objInterface.ifIndex & vbCrLf & _
" ifAdminStatus: " & objInterface.ifAdminStatus & vbCrLf & _
" ifDescr: " & objInterface.ifDescr & vbCrLf & _
" ifInDiscards: " & objInterface.ifInDiscards & vbCrLf & _
" ifInErrors: " & objInterface.ifInErrors & vbCrLf & _
" ifInNUcastPkts: " & objInterface.ifInNUcastPkts & vbCrLf & _
" ifInOctets: " & objInterface.ifInOctets & vbCrLf & _
" ifInUcastPkts: " & objInterface.ifInUcastPkts & vbCrLf & _
" ifInUnknownProtos: " & objInterface.ifInUnknownProtos & vbCrLf & _
" ifLastChange: " & objInterface.ifLastChange & vbCrLf & _
" ifMtu: " & objInterface.ifMtu & vbCrLf & _
" ifOperStatus: " & objInterface.ifOperStatus & vbCrLf & _
" ifOutDiscards: " & objInterface.ifOutDiscards & vbCrLf & _
" ifOutErrors: " & objInterface.ifOutErrors & vbCrLf & _
" ifOutNUcastPkts: " & objInterface.ifOutNUcastPkts & vbCrLf & _
" ifOutOctets: " & objInterface.ifOutOctets & vbCrLf & _
" ifOutQLen: " & objInterface.ifOutQLen & vbCrLf & _
" ifOutUcastPkts: " & objInterface.ifOutUcastPkts & vbCrLf & _
" ifPhysAddress: " & objInterface.ifPhysAddress & vbCrLf & _
" ifSpecific: " & objInterface.ifSpecific & vbCrLf & _
" ifSpeed: " & objInterface.ifSpeed & vbCrLf & _
" ifType: " & objInterface.ifType & vbCrLf
Next
I have 1 question :
- Set colIfTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_ifTable", , _
objWmiNamedValueSet)
This line is driving me crazy. I understand it retrieves all IP configuration.
Straight from the RFC 1759 or the Printer-mib, i want to have THIS oid ! (1.3.6.1.2.1.43.10.2.1.4).
I checked, it's in the "prtMarkerEntry" class.
But how the hell i can specify it ?
Whenever i put Set colIfTable = objWmiServices.InstancesOf("SNMP_RFC1759_MIB_prtmarkerentry", , _
objWmiNamedValueSet)
i have then an error on the "FOR LOOP". ColIfTable is empty. How all this work ?
I read so many things, i'm lost. Do i need to insert any MIB into the WMI repositery ? The famous mof files and all that ?
Thanks in advance everybody.
|
|
|
|
|
From my very limited research on the topic (good luck finding a "simple" example for this!), it would appear that you're missing the MIB data that describes to the SNMP Provider how to translate between SNMP data and WMI objects.
This would be done using an SNMP information module file and running it through the SMI2SMIR compiler. You would either need to find an SNMP module file for the SNMP output of the printer in question, or write one yourself. Or, better still, if the manufacturer of the printer supplies a MIB file for it, you'd need to import that MIB into the SMIR (SNMP Module Information Repository) by running smi2smir /a <MIB file> .
|
|
|
|
|