|
-
Nov 24th, 2009, 08:42 PM
#1
Thread Starter
Junior Member
Indexof Problem
So I have the first form working, more or less an exact copy of what i'm about to post, but the problem I'm running into is that indexof(textbox1.text + " total") is indeed searching for the right thing, but it's not SEEING it, is there any reason for this? Here's the code.
Code:
'WAREHOUSE
Dim SKUSheet2 As New ArrayList
Dim ReturnValueWH As Integer
Using MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser(ofdWarehouse.FileName)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(vbTab)
Dim currentRow1 As String()
While Not MyReader.EndOfData
Try
currentRow1 = MyReader.ReadFields()
Dim currentField As String
For Each currentField In currentRow1
SKUSheet2.Add(currentField)
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using
Dim Pachow As String = ""
Pachow = textSKU.ToString & " Total"
ReturnValueWH = SKUSheet2.IndexOf(Pachow.ToString)
If ReturnValueWH = -1 Then
textWarehouse.Text = "NOT FOUND"
Else
ReturnValueWH = ReturnValueWH + 1
textWarehouse.Text = SKUSheet2(ReturnValueWH)
Don't mind the pachow variable, I was tired and running out of variable names in my head. Now the format of the file is more or less like this.
SKU QUANTITY LOCATION
AD-DL-003 780 Q34-A
AD-DL-003 Total 780
AD-HP-026 10 Q12-A
A tab separates the columns in the file, it just doens't look like it here. It parses it correctly as far as I can tell, it outputs into a messagebox when i change it to do that. Why would it not be seeing the total part? Any ideas?
-
Nov 24th, 2009, 09:07 PM
#2
Fanatic Member
Re: Indexof Problem
Right here in the code :
Code:
Pachow = textSKU.ToString & " Total"
ReturnValueWH = SKUSheet2.IndexOf(Pachow.ToString)
If ReturnValueWH = -1 Then
try
Code:
Pachow = textSKU.ToString & " Total"
Label1.Text = "Pachow = " & Pachow & " SKUSheet2 = " & SKUSheet2' Get a look at exactly what Pachow is right here as well as SKUSheet2.
ReturnValueWH = SKUSheet2.IndexOf(Pachow.ToString)
If ReturnValueWH = -1 Then
 Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.
"Persistence is the magic of success." Paramahansa Yogananda
-
Nov 24th, 2009, 09:16 PM
#3
Thread Starter
Junior Member
Re: Indexof Problem
I must be an idiot, when I throw in what you said it says label1 not defined(I've never used anything called a label, but sounds familiar? like I said, I'm sure it's obvious I'm just dumb ), and the & operator does not belong to the arraylist class, but if what you're trying to do is see if it's showing " XXX-XX-XXX Total" I have looked at that through the debugger watch button and it shows "XXX-XX-XXX Total" like it should be, but for some reason it doesn't see it.
-
Nov 25th, 2009, 02:11 PM
#4
Thread Starter
Junior Member
Re: Indexof Problem
Anyone? Could really use the help! I only want hints preferably, been searing all over the documentation all day, and I can't figure it out.
-
Nov 25th, 2009, 03:50 PM
#5
Re: Indexof Problem
The thing is when you add the values to your arraylist, you only add the SKU number
Code:
SKUSheet2.Add(currentField)
However, the value you assigns to Pachow is some SKU number + " Total"
Code:
Pachow = textSKU.ToString & " Total"
And that's why when you do an indexof, it never finds the item in the array list because none of the items in the array list has the " Total" suffix.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Nov 25th, 2009, 05:53 PM
#6
Thread Starter
Junior Member
Re: Indexof Problem
I suppose the format of the source file is a bit misleading in the above post, there is a tab between the everything, except the SKU and the word total, that's a space, and the delimiter is set to a tab. I'm not sure why that doesn't translate into the post above, but that's how it looks. Or did I miss the point of your post entirely?
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
|