Results 1 to 6 of 6

Thread: Indexof Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    21

    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?

  2. #2
    Fanatic Member EntityX's Avatar
    Join Date
    Feb 2007
    Location
    Omnipresence
    Posts
    798

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    21

    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    21

    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.

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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 -

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    21

    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
  •  



Click Here to Expand Forum to Full Width