Click here to Skip to main content
15,559,491 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friendsa , i am creating a search page in vb.net.
here user will enter bill no in multile textbox (line by line ,one bill in one line)
this is my code .it ias working fine for comma seprated values.
but i want to use all values line by line .
how can i do it.
Thanks in Advance friends

VB
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim strArr() As String
        Dim itemcount As Integer
        Dim count As Integer
        Dim str As String = txtBillNo.Text
        Dim forlabel As String
        strArr = str.Split(',')
        For itemcount = 0 To strArr.Length - 1
            superTypeObj.PSearchText = strArr(itemcount)
            dsdata = superTypeObj.SearchCourierByBillno
            Dim row As DataRow = dsdata.Tables(0).Rows(0)
            count = dsSearch.Tables(0).Rows.Count
            If count <> 0 Then
                row = dsdata.Tables(0).Rows(0)
              dsSearch.Tables(0).Rows.Add(dsdata.Tables(0).Rows(0).ItemArray)
            Else
                forlabel += strArr(itemcount) & ", " & ""
            End If


        Next

        'superTypeObj.PSearchText = txtBillNo.Text

        ' dsSearch = superTypeObj.SearchCourierByBillno

        count = dsSearch.Tables(0).Rows.Count

        If count > 0 Then
            If count <= 15 Then
                Dg.PagerStyle.Visible = False
            End If
            Dg.DataSource = dsSearch
            Dg.DataBind()
            lblMsg.Text = "following" & forlabel & " Waybillnos are not correct "
        Else
            Dg.Visible = "False"

            lblMsg.Text = "following" & forlabel & " Waybillnos are not correct "
        End If
    End Sub
Posted
Updated 8-Jun-11 23:01pm
v2

Use str.Split(vbCrLf) for splitting multiline text.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 9-Jun-11 4:25am    
My 4. I added to improvements to your solution to make it complete.
Please see mine.
--SA
In addition to the solution by Prerak:

For compatibility, you really should use System.Environment.NewLine for delimiter. Very often it useful to use System.StringSplitOptions.RemoveEmptyEntries, see http://msdn.microsoft.com/en-us/library/system.stringsplitoptions.aspx#Y19[^] for a code sample.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900