Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27193

VS 2010 Searching strings and integers with a string

$
0
0
Hello,
I have a DataViewGrid linked to a BindingList. I'm attempting to implement a search function which searches every iteration in the list to see if it contains what is entered into the search textbox. If it's found then it changes the datasource to change the whole table to just contain the results. then you can click the refresh button it and brings up the whole table again.
Like this.
Code:

    Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchButton.Click
        SearchedInvoice.Clear()
        Dim searchtext As String = SearchBox.Text
        For Each Invoice In Invoices
            If Invoice.InvoiceNo.Contains(searchtext) Then
                SearchedInvoice.Add(Invoice)
                InvoiceDataGridView.DataSource = SearchedInvoice
                RefreshButton.Visible = True
            End If
        Next
    End Sub

But I need to expand this so it searches not only invoiceNo. (which is actually a string because it would say Donnelly0001, Donnelly0002, etc.) but also searching through integers like TotalCost. But because it reads what's in the textbox as a string it throws an error.

Any ideas on how I can make it search, Integers/doubles and strings to return results?

Viewing all articles
Browse latest Browse all 27193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>