Jumat, 07 Oktober 2011

Re: [ExcelVBA] Binary Search Problem

 

Enlightening.
 
I modified two lines thus
        If not (Dict_SD.exists(UCase(Sheet1.Cells(x, 1).Value))) Then
Sheet1.Cells(x, 4).Value = "Y"
        If not (Dict_PH.exists(ucase(Sheet1.Cells(x, 1).Value))) Then
Sheet1.Cells(x, 5).Value = "Y"
 
Regards
KC@103
pynasocas

From: Paul Schreiner <schreiner_paul@att.net>
To: ExcelVBA@yahoogroups.com
Sent: Friday, 7 October 2011 8:56 PM
Subject: Re: [ExcelVBA] Binary Search Problem

 
#2.. You're using an Interval Halving technique for searching the list.
However, for it to work properly, the data has to be sorted correctly.

Unfortunately, it doesn't look like it's sorting properly.
Specifically,
the ASCII code for "-" is 45
the ASCII code for "0" is 48
(1-9 are codes 49-57)

But in the sort, "-" is sorted AFTER numbers.
(see rows:
6115: 020-SUB-0011
6116: 02-16917-3600

12513: 400-TUNECVR-0003
12514: 40-26314
)

for that reason, when the interval happens to test lines comparing 020 to 02-,
it assumes that the 020 should be AFTER 02-, but the next iteration finds that
it is outside the range,
and therefore assumes it cannot find it.
I'm not sure what can be done about this sorting problem, however, I have an
alternate solution.
 
Paul

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar