Wrox Programmer Forums
|
BOOK: Professional Visual Basic 2010 and .NET 4
This is the forum to discuss the Wrox book Professional Visual Basic 2010 and .NET 4 by Bill Sheldon, Billy Hollis, Kent Sharkey, Gaston Hillar, Rob Windsor, Jonathan Marbutt; ISBN: 9780470502242
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Visual Basic 2010 and .NET 4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 4th, 2015, 10:45 PM
Registered User
 
Join Date: Sep 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter Two Sorting

I downloaded the sorting code in chapter 2, and it worked fine. I then added the Sort module, Person file and part of the Form code to my project. The project ran just like your code, except mine would not calculate the ages, and the resulting sort left the array just like it was. I found out that if I substituted a typed in date like this #7/1/2015# for my variable date, it would then calculate the ages. Is there some way to make your Sort code use dates and other information residing in variables? Here's the code I used.

Code:
' Get the last Id number in RLM42HD
                Dim LastRow As Integer = 0
                Dim LastId = From lId In db.RLM42HDs
                             Select lId.Id, lId.Date, lId.OrderNumber

                For Each lId In LastId
                    LastRow += 1
                Next

                Dim myPeople(LastRow - 1) As Person

                For Each lId In LastId
                    curId = lId.Id
                    curDate = lId.Date
                    myPeople(lId.Id - 1) = New Person(curId, curDate)    '-1 to accom. the array No's
                Next

                'Although this sort procedure works, it doesn't sort properly. If I replace the varitable curDate with an actual date, it works.????????????
                DoSort(myPeople, AddressOf Person.CompareAge)
BobE
 
Old September 18th, 2015, 11:04 PM
Registered User
 
Join Date: Sep 2015
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Please disregard my post.

I made a foolishly mistake, there is nothing wrong with the downloaded sort routine in chapter two. I didn't realize that I was trying to sort dates that were all in the same year and that I had to change the sort method from years to days-of-years; then it worked fine.
BobE
 
Old September 20th, 2015, 10:03 AM
Authorized User
 
Join Date: Mar 2015
Posts: 34
Thanks: 3
Thanked 2 Times in 2 Posts
Default

So at last it's working fine for you. LOL!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 11 Sorting Question coronoahcoro BOOK: Beginning Visual C# 2010 0 May 4th, 2012 09:24 AM
Chapter 8 - Table View (Sorting of Arrays in Table View) teamstar BOOK: Beginning iOS 5 Application Development 1 March 15th, 2012 10:30 PM
Chapter 17 - DataGrid Sorting Example Appled BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 4 March 28th, 2005 03:13 PM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.