tags:

views:

47

answers:

2
lot_no = "lot123"

s.indexof("lot123") does not return zero

whereas

s.indexof(lot_no) returns zero

has anyone seen a problem like this?

what does s contain?

    For Each s As String In split1
+1  A: 

Not sure what you're asking but this code returns -1 / -1

Dim lotnr As String = "lot123"
For Each s As String In "123asd"
    Debug.WriteLine(s.IndexOf("lot123"))
    Debug.WriteLine(s.IndexOf(lotnr))
Next

Use IndexOf this way:

Dim lotnr As String = "lot123"
For Each s As String In "123asd"
    Debug.WriteLine("lot123".IndexOf(s))
    Debug.WriteLine(lotnr.IndexOf(s))
Next

This results in: 3 3 4 4 5 5 -1 -1 -1 -1 -1 -1

rdkleine
interesting, can you please give me an example what the values of s in this case?
I__
ok, not so helpful but +1 for effort
I__
+1  A: 

K, looked add the code in your other thread. When I execute the following code I get a result, what am I doing wrong?

Public lot__no As String = "<Lot no>928374</Lot no>"
Sub DoSomething()
    Dim temp_string As String = "<beginning of record>ETCETCETC" 
   Dim myDelims As String() = New String() {"<beginning of record>"}
    Dim Split() As String = temp_string.Split(myDelims, StringSplitOptions.None)

    For Each s As String In Split
        If InStr(s, lot__no) <> 0 Then
            Debug.WriteLine("found" + s)
        End If
    Next
End Sub
rdkleine
the thing is, my friend, i am certain your code is fine, and i am certain my code is fine, but there must be a low-level problem PLEASE HELP
I__
Right, this seems a weird problem indeed. Have you tried creating a new application and tried this code again?
rdkleine