|
-
Oct 28th, 2009, 10:20 PM
#1
Thread Starter
Junior Member
Binarysearch returns -136?
So, I've got most of this figured out, I've got my text files read into an array. Which was step 1 (see my post earlier today if you're curious.)
My code so far is:
Note: textSKU is just a text box. No event handler associated.
Code:
Private Sub BtnSeacrch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSeacrch.Click
Dim objCA As New System.IO.StreamReader(ofdCA.FileName)
System.IO.StreamReader(ofdWarehouse.FileName)
'Dim StrLineCA As String
Dim SKUSheet() As String
Dim returnValueCA As String
Dim StrLineCA As String
StrLineCA = objCA.ReadToEnd
SKUSheet = StrLineCA.Split(System.Environment.NewLine)
Array.Sort(SKUSheet)
returnValueCA = Array.BinarySearch(SKUSheet, textSKU.Text)
MsgBox(SKUSheet(returnValueCA))
The message box is mostly just to test to see if it's finding the line. And the probleme is it's returning -136. Which I'm pretty sure can't be a value in the array ( actually very sure, as I tested it just to be sure, and it says it's out of bounds). I know it's in the array, as when I change returnvalueCA to a...7 for example, it outputs the correct line from the .csv file. Any ideas? Thanks in advance.
Tyler.
Edit: Index was outside the bounds of the array. is what the debugger says, as it's trying to output the value of SKUSheet(-136)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|