0
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

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

2 Comments

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
Right, this seems a weird problem indeed. Have you tried creating a new application and tried this code again?
1

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

1 Comment

interesting, can you please give me an example what the values of s in this case?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.