|
eg_Anubhava wrote: Yes Please check
I did, and select isn't broken.
eg_Anubhava wrote: I have a listbox in which have 20 items. But when i want to get number of items in Timer. But it displayed 0.
Try explaining something more. Did you create the items before you started the timer? Does the list "display" 0 items or does it "contain" 0 items?
Can you post your code here?
I are Troll
|
|
|
|
|
Hello Everybody,
Can any one explain it what is Flickers in vb.net. My friend suggest it Flickers is new concept of vb.net.
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: Can any one explain it what is Flickers in vb.net. My friend suggest it Flickers is new concept of vb.net.
No, it's not. Never heard of it. Ask your friend to explain what he means.
Google results for "vb.net flickers[^]".
|
|
|
|
|
Hi, i wanna make a bot, but i don´t know if it is possible to pass a value from a variable to a input text, through a WebBrowser. For example, use this bot to write a question in this site, the bot would be able to fill this message input! So, is it possible, and how can i do this using vb.net? thank you
|
|
|
|
|
ok, i think i solved it, i didn't had time to test it, but i found a code like this: webbrowser1.document.all.fieldname.value = TextBox1.Text
update:
the prewier code is just valid on vb6, for .net users the correct code is:
WebBrowser1.Document.GetElementById("fieldnam").InnerText = TextBox1.Text
modified on Monday, April 5, 2010 4:00 PM
|
|
|
|
|
Hello all
I wrote all of this stuff here Duplicate Files Finder[^] before I just saw that here are message boards and my questions aren't really much related to the Duplicate File Finder project.
Duplicate File Finder is a nice fast program and partly doing what I want to be done.
But I'm browsing the www for a few days now, trying to find a solution for my problem.
My current selfmade "solution" works, but as you will see, it's kinda simple and uncomfortable.
So maybe someone can help or give hints, that would really be appreciated.
I want to do this:
I have a folder with pictures I want to keep (that folder has different sub folders).
So I found hashdeep and use it to hash the files in the keep folder + subfolders and let it save the hashes in a txt file (hashes keep.txt). I use a batch file for that, the content changes so I have to re-hash after some time. Each line looks like this:
filesize,md5hash,sha-256hash,filename
Next I have a folder full of new pictures.
When I sort them, I sort out pictures I don't want to see again. So I use hashdeep to make another txt file database with hashes/files I don't want to see anymore when sorting files.
Then, everytime I get new pictures I use hashdeep to compare the new files with the 2 hash tables (using a batch file). It creates a text file containing the (full) file names of the found duplicate files in the new pictures folder. After that I use a batch file to open that text file and line by line delete each file listed in it, then delete the text file.
After that the new pics folder might still contain duplicate files. So I found HashMyFiles. It's kinda slow compared to eRRaTuM's Duplicated Files Finder and it processes all files without ignoring the files that exist only once in the new pics folder.
I use it to check the previously "cleaned" new pictures folder for double files. HashMyFiles gives each group of duplicate/multiple files an index and lets you sort by it. So I select all entries (except 1) of each group by hand and delete them.
After this the new pics folder contains only different files I might want to keep and files I don't yet have in my hash table file.
After sorting these pictures, I create new hashes of the new unwanted files with hashdeep and save to a new text file. I use a batch file to remove the 4 or 5 hashdeep info lines at the beginning of the file (creating a temp file, skipping the 1st lines, adding the new hash text file line by line to the temp file) and then add it (copy /B a + b ab) to the current hash table file after making a backup copy of it first.
And this game starts anew when I get new pictures.
So then I found eRRaTuM's program here on code project. It worked quite good, but for some reason I can't use it anymore after 1 day because I get a System.IO.FileNotFoundException when I want to process a folder. I don't know what causes this. It also would be just a better/faster replacement for HashMyFiles.
Sadly I don't know C# or C++, all I know is a little bit of VB.net. I just wrote me an image viewing/sorting program in VB.net, it works like I want it to, but I never learned how to code/script, so I'm kinda looking at other code like a sheep ;D
Is it possible to find an easy solution for all of this and maybe "import" the existing hashdeep hashtable files? I guess all I need might be the filesize (if needed for quicker comparison?) and the sha-256 hash, filename and md5 hash should be obsolete IMO.
Here again the options I want to achieve in a single program:
- compare files in a folder with informations in 2 hash databases, being able to list and delete found files with same hash in these databases
- look for duplicate files in a folder and list these found duplicate files, select all except one of each group (like Duplicate Files Finder does) and then delete them
- hash new files from a folder (the ones I don't want to see again after sorting) and add them to existing hash database
and maybe
- check existing hash database for double entries (which shouldn't be there though, but it wouldn't be bad to have such an option)
the more files I have in the new pictures folder and the more hashes in the database, the slower hashdeep becomes. I don't know if it's easy possible to make the new program use more threads/cores but that would speed things up I guess.
While looking for a solution I found code snippets and how to md5-hash files (I'd like hash-256 though since I already have these hashes and it means less collisions) but I have no idea how to get all of this done It's like a puzzle for me, snippets and no idea how to combine them.
Thanks for any advice/hint/place to look/other place to ask for help!
Nik
|
|
|
|
|
Imports System.Collections
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim airports As New Hashtable
airports.Add("JFK", "John F. Kennedy, New York")
airports.Add("LAX", "Los Angeles International, Los Angeles")
airports.Add("ORD", "O'Hare International, Chicago")
airports.Add("LHR", "Heathrow Airport, London")
MsgBox(airports.Item("JFK"))
End sub
Checkout for more you can do Retrieve All Values Sort & Iterate,etc...
http://www.java2s.com/Tutorial/VB/0160__Collections/0260__Hashtable.htm
|
|
|
|
|
just now I tried to convert erratum's duplicate file finder from c# to VB via converter - and it broke ... lol
1st thing I try to do right now is read all files in a folder and add the values into a hashtable.
for this I just need filename and sha-256 hash ...
I wished there would be more projects on the web with that topic ... :/
|
|
|
|
|
wow ok, that was kinda easy with code I found.
I am now able to hash a single file with openfiledialog -> hash -> show result in textbox
I think I'm able to hash all files in a folder, but then my knowledge ends for now.
I have to put the hashes in a hashtable.
Now I don't know what to do. What value is the key? the hash or the filename? IMO it's the hash since it shouldn't be duplicate (if I hash files in more than 1 folder there might be a filename collision)
but I guess this is the simplest part of the program I want to have.
edit: just was able to read the hash table txt files into a listview.
though I don't want the hashes from the files and the data from the text files to appear anywhere on the form, just the results (found hits (filenames))
modified on Tuesday, April 6, 2010 11:03 AM
|
|
|
|
|
alright ... sitting here for hours now, my head smokes XD
I tried different things.
I was able to parse my current hash text files, getting just the infos I want to.
I got them in Datasets/Datatables and also managed to read them into an access .mdb database.
displaying the info in datagridviews and listviews.
right now I'm at this point:
I can sha256-hash files in a folder, make a dataset with a datatable. the table (A) contains filesize, hash and filename.
then I can hash a text file with the hashes made my hashdeep.exe, I read filesize, hash and filename from it and put it into another dataset with datatable (B).
now I can't figure out (and I am reading for hours and only find useless information ) how to get each value line by line from the hash column in table (A) and look for hits in table (B)'s hash column, then display the whole row of table (A). Later -I think- it'll be sufficient to just get the filename and delete the files with it.
@_@
|
|
|
|
|
Hi,
I'm trying to design a login script using VB.net 2008 and the System.Data.SQLite wrapper. So far I have my SQLite tables setup with a default user (user: admin pass: test dob: 1990/01/01 name: John Smith) and I connect using the following code:
Imports System.Data.SQLite
Dim userName As String
Dim passWord As String
userName = usrBox.Text
passWord = passBox.Text
Dim sqlConnection As New SQLite.SQLiteConnection()
Dim sqlCommand As New SQLiteCommand
sqlConnection.ConnectionString = "Data Source=users.db3
sqlConnection.Open()
sqlCommand = sqlConnection.CreateCommand()
sqlCommand.CommandText = "SELECT * FROM users WHERE username = " & userName
However, I don't know how to check if the statement has rows for me to check if the user exists, and then I would have to do the same for passwords.
Anyone know how to check if the statement has rows using a similar function?
Cheers,
Ben.
|
|
|
|
|
You could use a "SELECT COUNT(*) ..." as SQL and then add something like this to your code:
Integer.Parse(sqlCommand.ExecuteScalar().ToString)
Another method is to create a DataTable first (using your SQL statement above):
Dim aDataTable As DataTable<br />
Dim aDbDataAdapter As DbDataAdapter<br />
<br />
sqlCommand.CommandText = sql<br />
aDbDataAdapter.SelectCommand = sqlCommand<br />
aDbDataAdapter.Fill(aDataTable)<br />
aDbDataAdapter.FillSchema(aDataTable, SchemaType.Source)<br />
aDataTable.TableName = tableName
and then evaluate the Row-Count:
aDataTable.Rows.Count
|
|
|
|
|
Maybe I have been looking at this too long.
I pass a DataTable,etc to the function. Summary values are calculated and new rows inserted at the appropriate places. The recursive part works good and the new rows are inserted into the correct place in the DataTable.
The problem occurs when the end of the DataTable is found and I call the Exit For statement, the Function should jump to the return statement, it however jumps to the Next statemnet and continues executing the loop.
Private Function SetNewDataRow(ByVal dt As DataTable, ByVal index As Integer, Optional ByVal fno As Integer = 0) As DataTable
Dim nra(13) As Object
nra = New Object() {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
nra(0) = "F" & (fno + 1).ToString & " Totals"
For i As Integer = index To dt.Rows.Count - 1
For j As Integer = 1 To dt.Columns.Count - 1
If TypeOf dt.Rows(i).Item(j) Is DBNull Then
nra(j) += 0
Else
nra(j) += CType(dt.Rows(i).Item(j), Double)
End If
Next
'--------------------------------------
' Debug Info -Display array contents
'--------------------------------------
Dim sb As New StringBuilder()
For n As Integer = 0 To 13
sb.Append(nra(n))
If n < 13 Then
sb.Append(", ")
End If
Next
Trace.WriteLine(sb.ToString)
'--------------------------------------
If i < dt.Rows.Count - 1 Then
If (Left(dt.Rows(i).Item(0).ToString, 4) <> Left(dt.Rows(i + 1).Item(0).ToString, 4)) Then
Dim nr As DataRow = dt.NewRow
nr.ItemArray = nra
dt.Rows.InsertAt(nr, i + 1)
'Exit For ' This works
SetNewDataRow(dt, i + 2, fno + 1)
End If
ElseIf i = dt.Rows.Count - 1 Then
Dim nr As DataRow = dt.NewRow
nr.ItemArray = nra
dt.Rows.Add(nr)
Exit For ' Problem here - Routine does not exit.
' Instead, jumps to the 'Next' statement
End If
Next
Return dt
End Function
I have tried numerous things, what am I missing?
(edited code)
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
modified on Monday, April 5, 2010 8:11 AM
|
|
|
|
|
The ElseIf at the bottom of loop will never be taken - the test is the same as previous If. So the Exit For will never execute.
The commented out Exit For is unnecessary - it is only taken when the end of loop condition is met so the loop would exit anyway.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Sorry David, there was a typo in the code sample.
I have found another way to do what I want, however, the behaviour of the recursive function is still perplexing. Note, I have tried this with a delegate Sub and still got the same weird behaviour.
Private Delegate Sub SetNewDataRow(ByRef dt as DataTable, ByVal index As Integer, _
ByVal fno As Integer)
Private Sub SetNewRow(ByRef dt as DataTable, ByVal index As Integer, _
Optional ByVal fno As Integer = 0)
...
If i < dt.Rows.Count - 1 Then
If (Left(dt.Rows(i).Item(0).ToString, 4) <> Left(dt.Rows(i + 1).Item(0).ToString, 4)) Then
nr = dt.NewRow
nr.ItemArray = nra
dt.Rows.InsertAt(nr, i + 1)
Dim del As New delRowSumm(AddressOf SetNewDataRow)
del(dt, i + 2, fno + 1)
End If
End If
Next
dt.Rows.Add(nra)
End Sub
It does evaluate i < dt.Rows.Count - 1 = False but jumps back into the For Loop
I got around it like this:
...
Dim fno As Integer = 0
Dim index as Integer = 0
While index <> -1
index = SummRow(dt, index, fn)
fno += 1
Loop
...
Private Function SummRow(ByRef dt As DataTable, ByVal index As Integer, _
ByVal fno As Integer) As Integer
Dim res As Integer = 0
Dim arr() As Object = {"F" & (fno + 1).ToString & " Totals", _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
For i As Integer = index To dt.Rows.Count - 1
For j As Integer = 1 To dt.Columns.Count - 1
If Not TypeOf dt.Rows(i).Item(j) Is DBNull Then
arr(j) += CType(dt.Rows(i).ItemArray(j), Double)
End If
Next
If i < dt.Rows.Count - 1 Then
If (Left(dt.Rows(i).Item(0).ToString, 4) <> Left(dt.Rows(i + 1).Item(0).ToString, 4)) Then
Dim nr As DataRow = dt.NewRow
nr.ItemArray = arr
dt.Rows.InsertAt(nr, i + 1)
res = i + 2
Exit For
End If
Else
dt.Rows.Add(arr)
res = -1
Exit For
End If
Next
Return res
End Function
I will keep digging at the original problem though.
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Here's some code that does what I think you are trying to do.
It's a function that returns a DataTable with the additional rows.
I'm not keen on adding/inserting rows in loops where the loop is controlled by the count of items in the table. I've seen situations where the count is evaluated only when the loop is entered so when rows are added/inserted in the loop fails to deal with some records. Don't know if VB.Net does this in it's For loop.
Private Function SummRow(ByRef dt As DataTable) As DataTable
'EDIT - Oops - has a bug that causes runtime error
End Function
OO buffs will not like the arr() of objects because it's not type safe. It also assumes the DataTable rows have a string followed by up to 13 numeric values.
This fixes bug.
Private Function SummRow(ByRef dt As DataTable) As DataTable
Dim tmp as DataTable = dt.Clone()
Dim rowNum As Integer = 0
Dim arr() As Object = {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Dim fNo As Integer = 0
Dim column0 as String
'Loop through the DataTable
While rowNum < dt.Rows.Count
'Set controls for next group of rows based on column0
fNo += 1
column0 = Left(dt.Rows(rowNum).Item(0).ToString, 4)
arr(0) = "F"& fno.ToString & " Totals"
'Loop through rows with same entry in column 0
While (rowNum < dt.Rows.Count) AndAlso (column0 = Left(dt.Rows(rowNum).Item(0).ToString, 4))
For colNum As Integer = 1 To dt.Columns.Count - 1
If Not TypeOf dt.Rows(rowNum).Item(colNum) Is DBNull Then
arr(colNum) += CType(dt.Rows(rowNum).ItemArray(colNum), Double)
End If
Next colNum
tmp.Rows.Add(dt.Rows(rowNum)
rowNum +=1
End While
'Add the running totals row on change of column0
Dim newRow as DataRow = tmp.NewRow
newRow.ItemArray = arr
tmp.Add(newRow)
End While
Return tmp
End Function
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
modified on Tuesday, April 6, 2010 3:32 AM
|
|
|
|
|
Are you aware that you could just replace the Exit For with a Return dt ?
If the only purpose of exiting the for loop is to finish the function, you can simply return the value. If it still doesn't execute the return , then you haven't gotten into that If block.
So, instead of:
ElseIf i = dt.Rows.Count - 1 Then
Dim nr As DataRow = dt.NewRow
nr.ItemArray = nra
dt.Rows.Add(nr)
Exit For
End If
ElseIf i = dt.Rows.Count - 1 Then
Dim nr As DataRow = dt.NewRow
nr.ItemArray = nra
dt.Rows.Add(nr)
return dt
End If
And are you stepping through the whole process? Is that where you're seeing that it's not getting to the return? Because if you are using recursion, after you call the SetNewDataRow recursively, after it returns, it's going to just to Next and it might appear like it didn't work.
|
|
|
|
|
Hi!
FOr the fun, I try to understand the recursivity in VB.net and I try to recreate a custom TreeView/TreeNode.
I progressively recreated the properties and methods of originals TreeView and TreeNode.
So, I have a customTreeView Class inheriting from Panel(for drawing with GDi), a customTreeNode class inheriting from Control and a customTreeNodeCollection inheriting from List(Of customTreeNode).
All customTreeNode instances and my instance of customTreeView have an instance of customTreeNodeCollection for storing childNodes.
I can add node the same way I do with originals TreeView ... with Add. But with the original, just after adding the childNodes to a parent node, if i check the "Level" property, it is already filled.
I don't understand, how, in my instance of customTreeNodeCollection, I can inform the Level of my New TreeNode.
I have to think well of recovering the level of the parent node and of adding +1 to it, but I does not manage either to recover parent TreeNode of the instance of this TreeNodeCollection.
Is there a trick know with recursivity ? or is there an other way to achieve it ?
Sorry for bad english
|
|
|
|
|
You do not tell it what level it is, all you do is set what the parent node is.
Look at the properties available, and the methods available on a tree node.
|
|
|
|
|
The level / depth of the current node compared to the node root ... or, the number of parents.
"Look at the properties available, and the methods available on a tree node."
Yes, it would be easy using the true TreeNode, but it is not my case, I start from scratch for my TreeNode while inheriting Control.
So my question is:
I have nested list of nested list of nested lists ......
I'm on a node, how-to get his parent node and therefore, his level
And I think I must attribute this level in the "Add" method of my customTreeNodeCollection class. But I don't know, from this class, how-to access the instance of customTreeNode who have instanciated this collection 
|
|
|
|
|
Look at Directory Recursion functions used for file systems, and apply the same principles to the nodes. i.e. have a function that can be called, pass in the current node, and keep a static count somewhere and keep walking up the parent until it is empty, then you will have the top (root node). and the depth to the node under test.
|
|
|
|
|
Hi,
Maybe there is no need to store the level, just calculate the value when it's needed by walking up the list of nodes via the Parent property. The root or top node has no parent and the Parent property will return null or Nothing when you get there.
The first example using a loop is probably easier to understand than the second recursive version.
public Int32 Level() {
Int32 levelValue = 0;
Node node = this;
while (node.Parent != null) {
levelValue = levelValue + 1;
node = node.Parent;
}
return levelValue;
}
public Int32 Level() {
if (this.Parent == null) {
return 0;
} else {
return Level() + 1;
}
}
Sorry about using c# in the Basic forum. If you can't decipher it, post back and I'll attempt a translation.
Alan.
|
|
|
|
|
I have searched in "Directory" for coll functions, but I don't know if it can serve me for my need.
Hi Alan N. As I sayed at start of this post, My first idea is to not using the real TreeNode and it's cool feature "Parent".
Since I want to write my own class inheriting "Control", I need to write my own property "Parent" because for controls, "Parent" is the parent control, and not the parent node.
I understand recursives functions for itering the child nodes (or child customTreeNodes in my List for my case), but I don't know how to make the same for going up in the parents.
I don't find simple examples on the web who make the same.
In any case, thank you for your suggestions which help me to consider the things in various ways.
|
|
|
|
|
Hi,
Yes, I understood that you would be implementing your own version of the parent property which is different from the Control.Parent property and I think I see what the problem is. You are able to travel down through the tree via the node collections but from your description I would guess that there are no upward links in place. That is, if you pick any node in your tree you could go down to find it's children but not up to it's parent.
To be able to go both up and down each node must contain two links
CLASS Node
NodeCollection children
NodeCollection parent
and importantly the NodeCollection must contain a link to it's parent node
CLASS NodeCollection
Node parent
The overall data structure is an example of a Doubly Linked List, complicated by the fact that the elements of the list are alternating Nodes and NodeCollections.
Alan.
|
|
|
|
|
Yes That's it. You have explained my problem better than me.
I succeeded in doing about what I wanted.
In the "Add" method of my customTreeNodeCollection, I call a recursive function which looks at all the children (and nested children) and informs their properties “Level” and “ParentNode”.
So, when I add a root node to the custom collection of my custom TreeView, this function can inform all the nodes
My custom TreeNodeCollection
Public Class cTreeNodeCollection
Inherits List(Of cNode)
Public Overloads Sub Add(ByVal node As cNode)
MyBase.Add(node)
SetAllLevelsAndParents(node.ChildNodes, 1, node)
End Sub
Private Sub SetAllLevelsAndParents(ByVal nodeList As List(Of cNode), ByVal level As Int32, ByVal parentNode As cNode)
For Each n As cNode In nodeList
Console.WriteLine(level & " | " & n.Text)
n.Level = level
n.ParentNode = parentNode
SetAllLevelsAndParents(n.ChildNodes, level + 1, n)
Next
End Sub
End Class
But your help will be very helpfull !
The answer for me, is to pass in parameters the current node and it's level for the recursive function.
With the level+1, i can inform the level of the childs, and with the node, I can inform the parent of the childs.
I don't know if it's a robust solution, but it seems working for the moment.
|
|
|
|
|