Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
Need Help! VB.Net Array Search
  • Alright VB.Net masters, show me what you got!

    See the code below?


    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Criteria As String = \"one*two*three*four\"
    Dim Input As String = TextBox1.Text
    Dim Raw() As String = Criteria.Split(\"*\")
    Dim i As Integer = Array.BinarySearch(Raw, Input)

    MsgBox(Raw(i))
    End Sub
    End Class


    I can enter texts in the TextBox1 field, and click the button to have it
    search for predefined arrays

    The structure should be like this:


    Raw(0) = \"one\"
    Raw(1) = \"two\"
    Raw(2) = \"three\"
    Raw(3) = \"four\"


    However, when I have it to search for "three" using BinarySearch as
    you can see, it returns a value of -2. What gives?

    Please lend me a hand guys!

    Am I making myself clear enough?