Icomparer And Sorting By File Dates?

Feb 18, 2010

I'm using Visual Studio .Net 2008 on Vista. The goal of my program is to watch a directory, get file information, then sort them by thier date, and produce a updated text file. I can't seem to get my code to generate a list of files sorted by date. The code does produce a general list of files, however presently ordered in the directory. I also tried an alternate way of sorting the files by date by creating a string, removing the date using substring, then comparing the file dates using datetime.parse but it produces a exception error. My first method using the structure follows:

[Code]...

View 1 Replies


ADVERTISEMENT

Sorting Structure According To Value Using IComparer?

Oct 27, 2010

I am using structures in my programming and I sort the structure according to a value in the structure using IComparer. How did Microsoft implement the Array.Sort() method? Is there any documentation (references) for this? Is it the same for all types of Sort() in Visual Basic?

This is a simple example for what I want.
Dim MyArray(6) As Integer
MyArray(0) = 1
MyArray(1) = 45
MyArray(2) = 45
[Code] .....

Array.Sort() will sort this array as: (1 1 1 10 45 45 57)

How does number 1 get sorted? Is it bringing to the end the first one or keeps the old one in the same index? In my original example (before sorting), MyArray(0) = 1 and after sorting MyArray(0) = 1. Is this the same original 1 or this another 1 (the newest one added to the array) moved to that position? In case the MyArray(0) = 1 after sorting should be MyArray(5) = 1 before sorting.

View 5 Replies

Sorting Dates In A Text File

May 10, 2011

how would it be possible to sort a text file?i have a file named "Alarms.txt" and I am using a streamwriter to save the date and time of the alarm into the file.What I want to do is everytime I insert a date and time, the text file sorts itself this is what the data inside the text file looks like (unsorted)

View 6 Replies

VS 2010 Sorting Datagridview By Dates Returned In Column?

Feb 3, 2012

I am using vb.net2010.

I am currently writing a bit of software for myself and need guidance.

I have a datagridview on a form with a date column. (column0)

I am trying to sort this by date desending but it will only sort by the day (dd) and not the whole date (dd/mm/yyyy) which leaves the months unsorted.

(example of output):
#1 - 01/03/2012
#2 - 02/01/2010
#3 - 03/02/2011

[code].....

View 2 Replies

Sorting "dd-mm-yyyy" Dates From A Listbox Item With Other Information?

Apr 22, 2011

With this code provided by a contributor from this forum ive been able to sort listbox items acording to date from older date to newer date, heres the

Dim dates() As Date = Array.ConvertAll(ListBox2.Items.Cast(Of String).ToArray, Function(s) Date.ParseExact(s, "dd-MM-yyyy", Nothing))
Array.Sort(dates)

[Code]....

How could i use that code to work these out based on only partial checking, what i mean with this is, to sort only by the first date or, to sort by the second date, i rather have it sorted by the first date before the arrow because that is the alarm, the after the arrow date is just the event date information.

View 16 Replies

.net - Performance Of Implementation Of IComparer?

Jul 14, 2011

I'm sorting a collection of type "Document" (usually around 100k records). Sorting usually takes around 4-5 seconds, and I'm wondering if there's a way to speed up sorting by modifying my "DocumentComparer" class which implements IComparer(Of Document). Since the Compare() method would be called hundreds of thousands of times, are there any performance improvements that could be made here that I've overlooked?

[Code]...

View 2 Replies

Asp.net - Error On An Icomparer Implementation

Nov 12, 2010

I created an array sorter to sort arrays like in Win Explorer in a DNN module. As in the answer to a preview question: Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET

[Code]....

View 1 Replies

Implementing Generic IComparer Of Own Class?

Jun 17, 2012

I am trying to create a class implementing the generic IComparer of my own class "Stellungen" (which translates to positions, like on a chess or checkers board).

This is what I got:
Private Class comparer(Of Stellung)
Implements System.Collections.Generic.IComparer(Of Stellung)
Public Function Compare(x As Stellung, y As Stellung) As Integer Implements System.Collections.Generic.IComparer(Of Stellung).Compare
End Function
End Class

Problem is: inside the function I have no access to any fields of my class. If I start off with x. Intellisense will only give me .Equals, .GetHashCode - the methods you get on a type but not on an instance. Visual Studio 10 also highlights this, in the definition of the function the bits "x as Stellung" and "y as Stellung" are written in light blue, meaning it is a type and not an actual object. How do I access the things I want to compare inside my class?

View 1 Replies

Sort Listview Using A Custom Icomparer ?

Jan 9, 2009

I'm trying to sort my listview using a custom icomparer. I have to sort numbers, strings, dates, and currency.

Here's the code to sort:

compareResult = ObjectCompare.Compare(listviewX.SubItems(ColumnToSort).Text, listviewY.SubItems(ColumnToSort).Text)

The problem is it sorts numbers wrong, such as:
10
2
3

instead of
2
3
10

View 3 Replies

Implementing IComparer For Custom Objects After Converting A Dictionary To SortedDictionary?

Jun 5, 2012

I'm having trouble implementing an IComparer method. Essentially, I want to compare the properties of two custom objects (the properties are of type integer).dE is a Dictionary(Of String, customObj)prTabIndex is a property of customObj and is of type Integer (these hold true for all examples)After some more searching I found this thread which suggested 3 things: a List approach, utilizing LINQ, and using some C# 3.0 features. I've tried three different ways:...rolling my own IComparer implementation:

Public m As Sub(ByRef d As Dictionary(of String, customObj))
Dim sortedD As New SortedDictionary(Of String, customObj)(d, myCompare)
End Sub

[code]....

Note that VS2008 has underlined 'dE.ToDictionary...' (to the end of the line) and giving me two messages depending on where I hover my mouse:

1) "Data type(s) of the type parameter(s) in extension method 'signature' As 'signature defined in 'System.Linq.Enumerable cannot be inferred from these arguments. Specifying the data types explicitly might correct this error. Seen while hovering over "ToDictionary".

2) Nested function does not have the same signature as delegate 'signature'. Seen while hovering over anything after "ToDictionary".

Q1) How far off am I in each of the implementations?

Q2) Which one is the computationally least expensive? Why?

Q3) Which one is the computationally most expensive? Why?

View 1 Replies

VS 2008 File Handling - Create A '.txt' File And Then Fill In The Dates And Times When The Program Is Opened

Oct 25, 2009

I want my program to be able to create a '.txt' file when it is run for the first time, with the date and time the program was accessed, and to be able to add new 'logs' of program history every time it is accessed. What i mean is that i want my program to be able to create a '.txt' file, and then fill in the dates and times when the program is opened.

View 7 Replies

VS 2008 How To Print All Dates Between These Two Dates In One Listbox

Feb 20, 2010

I have two dates. [code] How to print all dates between these two dates in one listbox, for example: [code]

View 8 Replies

File Sorting Using VB?

Jan 23, 2012

how to sort the files in the directory ?i'll have more than 500 no of files in the below format.

prod_orders_XXX_<TimeStamp>.dat
XXX = symbol of the product and the length may varies between 3-6.
<TimeStamp> = date and time

Multiple files for the same XXX are possible with different time stamps.Here are some examples:

prod_orders_abc_20122001083000.dat
prod_orders_abc_20122001083111.dat
prod_orders_xyz_20122001093157.dat

[code]....

View 1 Replies

Sorting A CSV File From Within An App

Mar 25, 2009

I have a VB.Net 2005 application in which I access a SQL Server DB to pull data into a Dataset. Within my app, this dataset is read sequentially. Then, a cross reference file is read against the dataset record. If there is a match (based on 2 fields from the dataset record), a field value from the cross reference file is used to replace a certain value in the dataset record. Once a dataset record has been read and processed...it is written to a new CSV file. This CSV file contains 5 columns.

I've been requested to now sort this new CSV file using 3 of the 5 columns as the "Sort Key". What would be the fastest way to do this?

I know one way would be to create a new dataset and insert the finished record into this new dataset in the order of the 3 fields (which I'm not sure how to setup).

View 8 Replies

Excel Sorting Is Only Sorting One Column Not Multiple?

Mar 12, 2012

I'm having my program sort an excel sheet by a few columns. However, it is only sorting by the first column not the rest that I specify.ere is my sort code below:

myRange.Sort(Key1:=myRange.Range("A:A"), Order1:=XlSortOrder.xlAscending, Key2:=myRange.Range("G:G"), Order2:=XlSortOrder.xlAscending, Header:=XlYesNoGuess.xlYes, Orientation:=XlSortOrientation.xlSortColumns)

[code]...

View 1 Replies

Wpf - Sorting Observable Collection Incorrectly Sorting?

Aug 20, 2011

I have a WPF ObservableCollection which is bound to a ListBox and I have a Sort() method which when called will convert the ObservableCollection to a List(Of T), and undertakes a sort based on a date/time column within the collection.

The data is sorted, even when new items are added to the ObservableCollection, however the date/time isn't being correctly sorted. The data is sorting based on the date however it is very much random when it comes to the time portion. The following is an example of the outcomes I am experiencing:

[Code]...

Is there anything that I am doing incorrectly in this method that would cause the time portion not be included in the sort? Is there a better way of doing a sort?

View 1 Replies

Dll File For Comparing Two Text Box Dates?

Feb 25, 2010

iwant to create an dll file for comparing two text box dates,, since in my project comparing dates is very necessry for every form,,so iwant to create an dll file,, here iam created an dll file but it was not working, here iam working with asp.net with vb.net..... here my code os given below,

Imports System
Imports Microsoft.VisualBasic
Namespace datecompare

[Code].....

View 7 Replies

Reading And Sorting A .CSV File?

Feb 3, 2009

I'm a relative novice when it comes to object oriented programming..

How can I use VB.net to efficiently read a large .CSV file, store the records (rows) in a table (an Object or an Array), and then sort them using multiple keys? (e.g. sort by Last Name and First Name) After some additional processing, the output will be written to another .CSV file.

View 8 Replies

Sorting Accounts In A .txt File?

Jun 21, 2011

I'm trying to make a simple program that stores my accounts in a .txt file. Each account has 3 properties, account, password, and source. I know there are alot of better ways to do this, but I'd really rather use a text file because I'm working with PhP also.

testacc1 password1 source1
testacc2 password2 source2
testacc3 password3 source3

I can easily write this to a .txt file, but how can I go through it?

View 5 Replies

Sorting Data From A File

Mar 8, 2010

Sorting data from a file

View 2 Replies

Sorting Of Existing File

Apr 21, 2009

This code is working but i have a few problem in sorting of existing file.. example. Output:

[Code]...

View 2 Replies

Program To Create A '.txt' File And Then Fill In Dates

Oct 25, 2009

I have been searching on the internet but couldn't find anything that would help me. I want my program to be able to create a '.txt' file when it is run for the first time, with the date and time the program was accessed, and to be able to add new 'logs' of program history every time it is accessed. What i mean is that i want my program to be able to create a '.txt' file, and then fill in the dates and times when the program is opened.

View 5 Replies

Reading Bunch Of Text File With Different Dates

Jul 31, 2009

Trying see why this isnt working. I am need to read a bunch of text file with different dates on the end sample is "impactstats_D_0731.txt

Dim oWrite As StreamWriter
Dim line As String
Dim spath As String
Dim readFile As System.IO.TextReader = New _
StreamReader("C:\Documents and Settings\Stats_Report\impactstats_D_*.txt")
line = readFile.ReadToEnd

View 2 Replies

Setting Times And Dates For File Names

Feb 16, 2012

Im using VB to set default dates and times for the file names when a form is saved through InfoPath, this is what I have so far:

[code...]

This works but i need to format it to this:

ddmmyyy and hhmmss

I need zero's before single characters as if its only a single character then it only displays 1 eg if its 9 in the morning it'll display 9 rather than 09 and i need 09.

View 4 Replies

Calculating Between Dates Based On Two Dates?

Jan 12, 2011

Say the user specifies these two dates....

Start Date: 2010-12-05
End Date: 2011-01-15

If I select December 2010 I should get the folllowing

startdate = 2010-12-05
enddate = 2010-12-31
Select January 2011 then
startdate = 2011-01-01
enddate = 2011-01-15

Should I subtract dates? How can I get the start and enddate for the current month/year based on the overall start and end date.I'm coding in vb.net.

View 1 Replies

Set The Start And End Dates For A Range Of Dates?

Oct 2, 2009

I'm using two datetimepicker controls to set the start and end dates for a range of dates I'm searching for.I want to make sure that the start date selected is not greater than the end date. This code works, but it runs the messagebox prompt twice for some reason. I've tried to ignore it from doing this, but it's not working. Can someone tell me what's wrong?

Private Sub dtpStart_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStart.ValueChanged

[Code]...

View 2 Replies

Reading, Reformating, And Sorting An .XLS File?

Aug 21, 2009

I have a spreadsheet in .XLS format that contains more than 60,000 rows with 12 columns per row. The first column contains the person's name (Last First Middle), which needs to be split into three columns by pushing columns 2 - 12 over into 4 - 14 and making 1, 2, and 3 the Last, First, and Middle Name columns. Then the file needs to be sorted by those three name fields and match-merged against the results of a SQL query (4,000+ records), which is being generated within the VB.net program.

Using VB.net, I can read the .XLS file, parse out the Name, and save the 14 columns into a 2-dimensional Object array. But I can't figure out how to sort it because 'Array.Sort(spreadsheet_table)' will only work on a 1-dimensional table. Maybe I shouldn't be using an Object, but I'm inexperienced enough that I couldn't get DataTable to work.

I'm writing the program as a "Console Application" using Visual Basic (VB.net) 2008 Express Edition in a Windows XP SP3 environment. The following is an example of the input data:

View 13 Replies

Sorting A Text File In VB 2008?

May 4, 2009

Ok so I know that you can sort by using a bunch of different sorting algorithms but I just am not sure how to start this off. I have written this code and just want to know if you can even sort this.

The program takes the users information in from text boxes from another part of the program and writes the information into a text file. So when the user clicks on this button it will display all the people that have entered in their names. I want to sort their last names alphabetticaly.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListCustomers.Click

[Code]...

View 6 Replies

Sorting After Reading Text File?

Jul 1, 2009

I would like to sort out the repeating lines after reading the text file.

For example i would like to sort:

VERSION 600
LIBRARY [2009/6/15 15:02:14, 2009/6/15 15:02:14] temp.gds
UNITS 0.001 1e-009

[Code]....

How do i continue from here to sort the textfile to get what i want?

View 3 Replies

Sorting Text File By Column?

Dec 9, 2011

how to sort .txt file by first column and the second column the first row is the header

<ticker>,<date>,<opening>,<high>,<low>,<close,<vol>
RIBL,20100329,30.1,30.3,30.1,30.2,205085
RIBL,20100330,30.3,30.5,30.3,30.5,405092

[code]....

View 14 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved